diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2007-11-20 14:28:05 +0000 |
---|---|---|
committer | <> | 2013-08-08 17:01:04 +0000 |
commit | c97631728ce7d6d3f4692a56c3cda7476b42a968 (patch) | |
tree | 8c00053771ccae41a737eecd072dbb3cd8b06fdd /t/stream.t | |
download | perl-xml-parser-master.tar.gz |
Imported from /home/lorry/working-area/delta_perl-xml-parser/XML-Parser-2.36.tar.gz.HEADXML-Parser-2.36master
Diffstat (limited to 't/stream.t')
-rw-r--r-- | t/stream.t | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/t/stream.t b/t/stream.t new file mode 100644 index 0000000..92b7994 --- /dev/null +++ b/t/stream.t @@ -0,0 +1,50 @@ +BEGIN {print "1..3\n";} +END {print "not ok 1\n" unless $loaded;} +use XML::Parser; +$loaded = 1; +print "ok 1\n"; + +my $delim = '------------123453As23lkjlklz877'; +my $file = 'samples/REC-xml-19980210.xml'; +my $tmpfile = 'stream.tmp'; + +my $cnt = 0; + + +open(OUT, ">$tmpfile") or die "Couldn't open $tmpfile for output"; +open(IN, $file) or die "Couldn't open $file for input"; + +while (<IN>) { + print OUT; +} + +close(IN); +print OUT "$delim\n"; + +open(IN, $file); +while (<IN>) { + print OUT; +} + +close(IN); +close(OUT); + +my $parser = new XML::Parser(Stream_Delimiter => $delim, + Handlers => {Comment => sub {$cnt++;}}); + +open(FOO, $tmpfile); + +$parser->parse(*FOO); + +print "not " if ($cnt != 37); +print "ok 2\n"; + +$cnt = 0; + +$parser->parse(*FOO); + +print "not " if ($cnt != 37); +print "ok 3\n"; + +close(FOO); +unlink($tmpfile); |