summaryrefslogtreecommitdiff
path: root/t/skip.t
diff options
context:
space:
mode:
authorHyungKyu Song <hk76.song@samsung.com>2013-02-16 00:50:36 +0900
committerHyungKyu Song <hk76.song@samsung.com>2013-02-16 00:50:36 +0900
commit160d5709e9eeb46402ee708d93baca1922d84c4d (patch)
treeffa173d67e3f5bfbb651c20ef553c4882c8b0d7b /t/skip.t
parent3555375b5b187f5eb25bc6673e2479d54f20ada3 (diff)
downloadperl-XML-Parser-46d5c395a331f31c2446a4bfb28247aff29ec50b.tar.gz
perl-XML-Parser-46d5c395a331f31c2446a4bfb28247aff29ec50b.tar.bz2
perl-XML-Parser-46d5c395a331f31c2446a4bfb28247aff29ec50b.zip
Diffstat (limited to 't/skip.t')
-rw-r--r--t/skip.t53
1 files changed, 53 insertions, 0 deletions
diff --git a/t/skip.t b/t/skip.t
new file mode 100644
index 0000000..6cde2a7
--- /dev/null
+++ b/t/skip.t
@@ -0,0 +1,53 @@
+BEGIN {print "1..4\n";}
+END {print "not ok 1\n" unless $loaded;}
+use XML::Parser;
+$loaded = 1;
+print "ok 1\n";
+
+my $cmnt_count = 0;
+my $pi_count = 0;
+my $between_count = 0;
+my $authseen = 0;
+
+sub init {
+ my $xp = shift;
+ $xp->skip_until(1); # Skip through prolog
+}
+
+sub proc {
+ $pi_count++;
+}
+
+sub cmnt {
+ $cmnt_count++;
+}
+
+sub start {
+ my ($xp, $el) = @_;
+ my $ndx = $xp->element_index;
+ if (! $authseen and $el eq 'authlist') {
+ $authseen = 1;
+ $xp->skip_until(2000);
+ }
+ elsif ($authseen and $ndx < 2000) {
+ $between_count++;
+ }
+}
+
+my $p = new XML::Parser(Handlers => {Init => \&init,
+ Start => \&start,
+ Comment => \&cmnt,
+ Proc => \&proc
+ });
+
+$p->parsefile('samples/REC-xml-19980210.xml');
+
+print "not " if $between_count;
+print "ok 2\n";
+
+print "not " if $pi_count;
+print "ok 3\n";
+
+print "not " unless $cmnt_count == 5;
+print "ok 4\n";
+