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/defaulted.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/defaulted.t')
-rw-r--r-- | t/defaulted.t | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/t/defaulted.t b/t/defaulted.t new file mode 100644 index 0000000..a3dfb91 --- /dev/null +++ b/t/defaulted.t @@ -0,0 +1,50 @@ +BEGIN {print "1..4\n";} +END {print "not ok 1\n" unless $loaded;} +use XML::Parser; +$loaded = 1; +print "ok 1\n"; + +$doc =<<'End_of_Doc;'; +<!DOCTYPE foo [ +<!ATTLIST bar zz CDATA 'there'> +]> +<foo> + <bar xx="hello"/> + <bar zz="other"/> +</foo> +End_of_Doc; + +sub st { + my $xp = shift; + my $el = shift; + + if ($el eq 'bar') { + my %atts = @_; + my %isdflt; + my $specified = $xp->specified_attr; + + for (my $i = $specified; $i < @_; $i += 2) { + $isdflt{$_[$i]} = 1; + } + + if (defined $atts{xx}) { + print 'not ' + if $isdflt{'xx'}; + print "ok 2\n"; + + print 'not ' + unless $isdflt{'zz'}; + print "ok 3\n"; + } + else { + print 'not ' + if $isdflt{'zz'}; + print "ok 4\n"; + } + + } +} + +$p = new XML::Parser(Handlers => {Start => \&st}); + +$p->parse($doc); |