1# Hey Emacs, this is -*- perl -*- !
2#
3# Before `make install' is performed this script should be runnable with
4# `make test'. After `make install' it should work as `perl test.pl'
5#
6# $Id: amsterdam.t,v 1.1 1999/08/28 17:46:57 kmacleod Exp $
7#
8
9######################### We start with some black magic to print on failure.
10
11# Change 1..1 below to 1..last_test_to_print .
12# (It may become useful if the test is moved to ./t subdirectory.)
13
14BEGIN { $| = 1; print "1..2\n"; }
15END {print "not ok 1\n" unless $loaded;}
16use XML::Parser::PerlSAX;
17use XML::PatAct::MatchName;
18use XML::PatAct::Amsterdam;
19
20
21$loaded = 1;
22print "ok 1\n";
23
24$patterns =
25    [
26     'outer' => { Before => "Outer-before, '[attr]'",
27		  After => "Outer-after\n" },
28     'inner' => { Before => "Inner" },
29     ];
30
31my $matcher = XML::PatAct::MatchName->new( Patterns => $patterns );
32my $handler = XML::PatAct::Amsterdam->new( Patterns => $patterns,
33					   Matcher => $matcher,
34					   AsString => 1 );
35my $parser = XML::Parser::PerlSAX->new( Handler => $handler );
36$string = $parser->parse(Source => { String => <<'EOF;' } );
37<outer attr='an attr'>
38  <inner/>
39</outer>
40EOF;
41
42$expected = <<"EOF;";
43Outer-before, 'an attr'
44  Inner
45Outer-after
46EOF;
47
48print (($string eq $expected) ? "ok 2\n" : "not ok 2\n");
49