r15941 - in /branches/upstream/libtest-xml-simple-perl: ./ current/ current/lib/ current/lib/Test/ current/lib/Test/XML/ current/t/
jaldhar at users.alioth.debian.org
jaldhar at users.alioth.debian.org
Fri Feb 29 02:39:49 UTC 2008
Author: jaldhar
Date: Fri Feb 29 02:39:48 2008
New Revision: 15941
URL: http://svn.debian.org/wsvn/?sc=1&rev=15941
Log:
[svn-inject] Installing original source of libtest-xml-simple-perl
Added:
branches/upstream/libtest-xml-simple-perl/
branches/upstream/libtest-xml-simple-perl/current/
branches/upstream/libtest-xml-simple-perl/current/Changes
branches/upstream/libtest-xml-simple-perl/current/MANIFEST
branches/upstream/libtest-xml-simple-perl/current/META.yml
branches/upstream/libtest-xml-simple-perl/current/Makefile.PL
branches/upstream/libtest-xml-simple-perl/current/README
branches/upstream/libtest-xml-simple-perl/current/lib/
branches/upstream/libtest-xml-simple-perl/current/lib/Test/
branches/upstream/libtest-xml-simple-perl/current/lib/Test/XML/
branches/upstream/libtest-xml-simple-perl/current/lib/Test/XML/Simple.pm
branches/upstream/libtest-xml-simple-perl/current/t/
branches/upstream/libtest-xml-simple-perl/current/t/01load.t
branches/upstream/libtest-xml-simple-perl/current/t/02import.t
branches/upstream/libtest-xml-simple-perl/current/t/03valid.t
branches/upstream/libtest-xml-simple-perl/current/t/04node.t
branches/upstream/libtest-xml-simple-perl/current/t/05is.t
branches/upstream/libtest-xml-simple-perl/current/t/06like.t
branches/upstream/libtest-xml-simple-perl/current/t/07deeply.t
branches/upstream/libtest-xml-simple-perl/current/t/08attr.t
branches/upstream/libtest-xml-simple-perl/current/t/pod-coverage.t
branches/upstream/libtest-xml-simple-perl/current/t/pod.t
Added: branches/upstream/libtest-xml-simple-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-xml-simple-perl/current/Changes?rev=15941&op=file
==============================================================================
--- branches/upstream/libtest-xml-simple-perl/current/Changes (added)
+++ branches/upstream/libtest-xml-simple-perl/current/Changes Fri Feb 29 02:39:48 2008
@@ -1,0 +1,47 @@
+Revision history for Perl extension Test::XML::Simple.
+
+0.09 Tue Dec 20 17:20:44 PST 2005
+ - xml_like did not return a true value when it
+ works properly.
+
+0.08 Tue Dec 20 16:04:14 PST 2005
+ - Make sure the backup error message for xml_like
+ includes the user's supplied comment.
+
+0.07 Tue Dec 20 14:25:52 PST 2005
+ - change xml_like to search through all text and
+ CDATA sections whe doing a match.
+
+0.06 Fri Dec 9 16:42:11 PST 2005
+ - Fixed some really egregious errors in the
+ XML comparisons. (Note to self: find *all*
+ the interface differences next time!)
+ - added _long versions of the test functions.
+ these use Test::More's comparisons. The
+ xml_is, xml_like, and xml_is_deeply
+ functions all use Test::Longstring, for
+ those who want the same tests, less filling.
+
+0.05 Mon Nov 28 14:41:58 2005
+ - Switched to XML::LibXML
+ - reordered Test::Tester to the top in all tests
+ - fixed test tests that had no result testing
+ - tests now fail with the appropriate message
+ instead of diag'ing it
+
+0.04 Wed Sep 14 14:43:10 2005
+ - Fixed xml_is and xml_like to handle attributes better
+ (//node[@attr] will now actually return the value of the
+ attribute instead of dying)
+
+0.03 Thu Sep 8 17:36:52 2005
+ - Updated docs (included docs for xml_is_deeply)
+ - Added tests
+
+0.02 Thu Apr 21 14:05:42 2005
+ - added Test::Tester to the prereqs (oops).
+
+0.01 Tue Mar 1 08:18:07 2005
+ - original version; created by h2xs 1.21 with options
+ -AX -n Test::XML::Simple
+
Added: branches/upstream/libtest-xml-simple-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-xml-simple-perl/current/MANIFEST?rev=15941&op=file
==============================================================================
--- branches/upstream/libtest-xml-simple-perl/current/MANIFEST (added)
+++ branches/upstream/libtest-xml-simple-perl/current/MANIFEST Fri Feb 29 02:39:48 2008
@@ -1,0 +1,16 @@
+Changes
+lib/Test/XML/Simple.pm
+Makefile.PL
+MANIFEST
+README
+t/01load.t
+t/02import.t
+t/03valid.t
+t/04node.t
+t/05is.t
+t/06like.t
+t/07deeply.t
+t/08attr.t
+t/pod-coverage.t
+t/pod.t
+META.yml Module meta-data (added by MakeMaker)
Added: branches/upstream/libtest-xml-simple-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-xml-simple-perl/current/META.yml?rev=15941&op=file
==============================================================================
--- branches/upstream/libtest-xml-simple-perl/current/META.yml (added)
+++ branches/upstream/libtest-xml-simple-perl/current/META.yml Fri Feb 29 02:39:48 2008
@@ -1,0 +1,14 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
+name: Test-XML-Simple
+version: 0.09
+version_from: lib/Test/XML/Simple.pm
+installdirs: site
+requires:
+ Test::Builder: 0
+ Test::More: 0
+ Test::Tester: 0
+ XML::LibXML: 0
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.28
Added: branches/upstream/libtest-xml-simple-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-xml-simple-perl/current/Makefile.PL?rev=15941&op=file
==============================================================================
--- branches/upstream/libtest-xml-simple-perl/current/Makefile.PL (added)
+++ branches/upstream/libtest-xml-simple-perl/current/Makefile.PL Fri Feb 29 02:39:48 2008
@@ -1,0 +1,17 @@
+use ExtUtils::MakeMaker;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+WriteMakefile(
+ 'NAME' => 'Test::XML::Simple',
+ 'VERSION_FROM' => 'lib/Test/XML/Simple.pm', # finds $VERSION
+ 'PREREQ_PM' => {
+ Test::Builder => 0,
+ Test::Tester => 0,
+ Test::More => 0,
+ XML::LibXML => 0,
+ }, # e.g., Module::Name => 1.1
+ ($] >= 5.005 ? ## Add these new keywords supported since 5.005
+ (ABSTRACT_FROM => 'lib/Test/XML/Simple.pm',
+ # retrieve abstract from module
+ AUTHOR => 'Joe McMahon <mcmahon at cpan.org>') : ()),
+);
Added: branches/upstream/libtest-xml-simple-perl/current/README
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-xml-simple-perl/current/README?rev=15941&op=file
==============================================================================
--- branches/upstream/libtest-xml-simple-perl/current/README (added)
+++ branches/upstream/libtest-xml-simple-perl/current/README Fri Feb 29 02:39:48 2008
@@ -1,0 +1,37 @@
+Test::XML::Simple version 0.01
+============================
+
+Test::SML::Simple provides a test class which makes it easy to do basic
+Test::Builder-style tests on XML input.
+
+ use Test::XML::Simple test=>4;
+ is_valid $xml, "Is valid XML";
+ xml_node $xml, "/xpath/expression", "specified xpath node is present";
+ xml_text_is $xml, '/xpath/expr', "expected value", "specified text present";
+ xml_text_like $xml, '/xpath/expr', qr/expected/, "regex text present";
+ xml_is_deeply $xml, '/xpath/expr', $xml_fragment, "fragment matches path";
+
+INSTALLATION
+
+To install this module type the following:
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+DEPENDENCIES
+
+This module requires these other modules and libraries:
+
+ Test::Builder
+ Test::More
+ XML::XPath
+
+COPYRIGHT AND LICENCE
+
+Copyright (C) 2005 by Yahoo!
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself, either Perl version 5.6.1 or,
+at your option, any later version of Perl 5 you may have available.
Added: branches/upstream/libtest-xml-simple-perl/current/lib/Test/XML/Simple.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-xml-simple-perl/current/lib/Test/XML/Simple.pm?rev=15941&op=file
==============================================================================
--- branches/upstream/libtest-xml-simple-perl/current/lib/Test/XML/Simple.pm (added)
+++ branches/upstream/libtest-xml-simple-perl/current/lib/Test/XML/Simple.pm Fri Feb 29 02:39:48 2008
@@ -1,0 +1,267 @@
+package Test::XML::Simple;
+
+use strict;
+use warnings;
+
+our $VERSION = '0.09';
+
+use Test::Builder;
+use Test::More;
+use Test::LongString;
+use XML::LibXML;
+
+my $Test = Test::Builder->new();
+my $Xml;
+my $last_xml_string = "";
+
+sub import {
+ my $self = shift;
+ my $caller = caller;
+ no strict 'refs';
+ *{$caller.'::xml_valid'} = \&xml_valid;
+ *{$caller.'::xml_node'} = \&xml_node;
+ *{$caller.'::xml_is'} = \&xml_is;
+ *{$caller.'::xml_is_long'} = \&xml_is_long;
+ *{$caller.'::xml_is_deeply'} = \&xml_is_deeply;
+ *{$caller.'::xml_is_deeply_long'} = \&xml_is_deeply_long;
+ *{$caller.'::xml_like'} = \&xml_like;
+ *{$caller.'::xml_like_long'} = \&xml_like_long;
+
+ $Test->exported_to($caller);
+ $Test->plan(@_);
+}
+
+sub xml_valid($;$) {
+ my ($xml, $comment) = @_;
+ my $parsed_xml = _valid_xml($xml);
+ return 0 unless $parsed_xml;
+
+ ok $parsed_xml, $comment;
+}
+
+sub _valid_xml {
+ my $xml = shift;
+ return $Xml if defined($xml) and $xml eq $last_xml_string;
+
+ return fail("XML is not defined") unless defined $xml;
+ return fail("XML is missing") unless $xml;
+ return fail("string can't contain XML: no tags")
+ unless ($xml =~ /</ and $xml =~/>/);
+ eval {$Xml = XML::LibXML->new->parse_string($xml)};
+ $@ ? return fail($@)
+ : return $Xml;
+}
+
+sub _find {
+ my ($xml_xpath, $xpath) = @_;
+ my @nodeset = $xml_xpath->findnodes($xpath);
+ return fail("Couldn't find $xpath") unless @nodeset;
+ wantarray ? @nodeset : \@nodeset;
+}
+
+
+sub xml_node($$;$) {
+ my ($xml, $xpath, $comment) = @_;
+
+ my $parsed_xml = _valid_xml($xml);
+ return 0 unless $parsed_xml;
+
+ my $nodeset = _find($parsed_xml, $xpath);
+ return 0 if !$nodeset;
+
+ ok(scalar @$nodeset, $comment);
+}
+
+
+sub xml_is($$$;$) {
+ _xml_is(\&is_string, @_);
+}
+
+sub xml_is_long($$$;$) {
+ _xml_is(\&is, @_);
+}
+
+sub _xml_is {
+ my ($comp_sub, $xml, $xpath, $value, $comment) = @_;
+
+ my $parsed_xml = _valid_xml($xml);
+ return 0 unless $parsed_xml;
+
+ my $nodeset = _find($parsed_xml, $xpath);
+ return 0 if !$nodeset;
+
+ foreach my $node (@$nodeset) {
+ my @kids = $node->getChildNodes;
+ if (@kids) {
+ $comp_sub->($kids[0]->toString, $value, $comment);
+ }
+ else {
+ my $got = $node->toString;
+ $got =~ s/^.*="(.*)"/$1/;
+ is $got, $value, $comment;
+ }
+ }
+}
+
+sub xml_is_deeply($$$;$) {
+ _xml_is_deeply(\&is_string, @_);
+}
+
+sub xml_is_deeply_long($$$;$) {
+ _xml_is_deeply(\&is, @_);
+}
+
+sub _xml_is_deeply {
+ my ($is_sub, $xml, $xpath, $candidate, $comment) = @_;
+
+ my $parsed_xml = _valid_xml($xml);
+ return 0 unless $parsed_xml;
+
+ my $candidate_xp;
+ eval {$candidate_xp = XML::LibXML->new->parse_string($candidate) };
+ return 0 unless $candidate_xp;
+
+ my $parsed_thing = $parsed_xml->findnodes($xpath)->[0];
+ my $candidate_thing = $candidate_xp->findnodes('/')->[0];
+
+ $candidate_thing = $candidate_thing->documentElement
+ if $parsed_thing->isa('XML::LibXML::Element');
+
+ $is_sub->($parsed_thing->toString,
+ $candidate_thing->toString,
+ $comment);
+}
+
+sub xml_like($$$;$) {
+ _xml_like(\&like_string, @_);
+}
+
+sub xml_like_long($$$;$) {
+ _xml_like(\&like, @_);
+}
+
+sub _xml_like {
+ my ($like_sub, $xml, $xpath, $regex, $comment) = @_;
+
+ my $parsed_xml = _valid_xml($xml);
+ return 0 unless $parsed_xml;
+
+ my $nodeset = _find($parsed_xml, $xpath);
+ return 0 if !$nodeset;
+
+ foreach my $node (@$nodeset) {
+ my @kids = $node->getChildNodes;
+ my $found;
+ if (@kids) {
+ foreach my $kid (@kids) {
+ if ($kid->toString =~ /$regex/) {
+ $found = 1;
+ return $like_sub->($kid->toString, $regex, $comment);
+ }
+ }
+ if (! $found) {
+ $comment = "(no comment)" unless defined $comment;
+ return ok(0, "$comment - no match in tag contents (including CDATA)");
+ }
+ }
+ else {
+ my $got = $node->toString;
+ $got =~ s/^.*="(.*)"/$1/;
+ return $like_sub->(like $got, $regex, $comment);
+ }
+ }
+}
+
+1;
+__END__
+
+=head1 NAME
+
+Test::XML::Simple - easy testing for XML
+
+=head1 SYNOPSIS
+
+ use Test::XML::Simple tests=>5;
+ xml_valid $xml, "Is valid XML";
+ xml_node $xml, "/xpath/expression", "specified xpath node is present";
+ xml_is, $xml, '/xpath/expr', "expected value", "specified text present";
+ xml_like, $xml, '/xpath/expr', qr/expected/, "regex text present";
+ xml_is_deeply, $xml, '/xpath/expr', $xml2, "structure and contents match";
+
+ # Not yet implemented:
+ # xml_like_deeply would be nice too...
+
+=head1 DESCRIPTION
+
+C<Test::XML::Simple> is a very basic class for testing XML. It uses the XPath
+syntax to locate nodes within the XML. You can also check all or part of the
+structure vs. an XML fragment.
+
+=head1 TEST ROUTINES
+
+=head2 xml_valid $xml, 'test description'
+
+Pass an XML file or fragment to this test; it succeeds if the XML (fragment)
+is valid.
+
+=head2 xml_node $xml, $xpath, 'test description'
+
+Checks the supplied XML to see if the node described by the supplied XPath
+expression is present. Test fails if it is not present.
+
+=head2 xml_is_long $xml, $xpath, $value, 'test description'
+
+Finds the node corresponding to the supplied XPath expression and
+compares it to the supplied value. Succeeds if the two values match.
+Uses Test::More's C<is> function to do the comparison.
+
+=head2 xml_is $xml, $xpath, $value, 'test description'
+
+Finds the node corresponding to the supplied XPath expression and
+compares it to the supplied value. Succeeds if the two values match.
+Uses Test::LongString's C<is_string> function to do the test.
+
+=head2 xml_like_long $xml, $xpath, $regex, 'test description'
+
+Find the XML corresponding to the the XPath expression and check it
+against the supplied regular expression. Succeeds if they match.
+Uses Test::More's C<like> function to do the comparison.
+
+=head2 xml_like $xml, $xpath, $regex, 'test description'
+
+Find the XML corresponding to the the XPath expression and check it
+against the supplied regular expression. Succeeds if they match.
+Uses Test::LongString's C<like_string> function to do the test.
+
+=head2 xml_is_deeply_long $xml, $xpath, $xml2, 'test description'
+
+Find the piece of XML corresponding to the XPath expression,
+and compare its structure and contents to the second XML
+(fragment) supplied. Succeeds if they match in structure and
+content. Uses Test::More's C<is> function to do the comparison.
+
+=head2 xml_is_deeply $xml, $xpath, $xml2, 'test description'
+
+Find the piece of XML corresponding to the XPath expression,
+and compare its structure and contents to the second XML
+(fragment) supplied. Succeeds if they match in structure and
+content. Uses Test::LongString's C<is_string> function to do the test.
+
+=head1 AUTHOR
+
+Joe McMahon, E<lt>mcmahon at cpan.orgE<gt>
+
+=head1 LEGAL
+
+Copyright (c) 2005 by Yahoo!
+
+This library is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself, either Perl version 5.6.1 or, at
+your option, any later version of Perl 5 you may have available.
+
+=head1 SEE ALSO
+
+L<XML::XPath>, L<Test::More>, L<Test::Builder>.
+
+
+=cut
Added: branches/upstream/libtest-xml-simple-perl/current/t/01load.t
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-xml-simple-perl/current/t/01load.t?rev=15941&op=file
==============================================================================
--- branches/upstream/libtest-xml-simple-perl/current/t/01load.t (added)
+++ branches/upstream/libtest-xml-simple-perl/current/t/01load.t Fri Feb 29 02:39:48 2008
@@ -1,0 +1,2 @@
+use Test::More tests => 1;
+use_ok("Test::XML::Simple");
Added: branches/upstream/libtest-xml-simple-perl/current/t/02import.t
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-xml-simple-perl/current/t/02import.t?rev=15941&op=file
==============================================================================
--- branches/upstream/libtest-xml-simple-perl/current/t/02import.t (added)
+++ branches/upstream/libtest-xml-simple-perl/current/t/02import.t Fri Feb 29 02:39:48 2008
@@ -1,0 +1,8 @@
+use Test::More tests => 5;
+use Test::XML::Simple;
+
+ok(defined \&xml_valid, "xml_valid imported");
+ok(defined \&xml_node, "xml_node imported");
+ok(defined \&xml_is, "xml_is imported");
+ok(defined \&xml_is_deeply, "xml_is_deeply imported");
+ok(defined \&xml_like, "xml_like imported");
Added: branches/upstream/libtest-xml-simple-perl/current/t/03valid.t
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-xml-simple-perl/current/t/03valid.t?rev=15941&op=file
==============================================================================
--- branches/upstream/libtest-xml-simple-perl/current/t/03valid.t (added)
+++ branches/upstream/libtest-xml-simple-perl/current/t/03valid.t Fri Feb 29 02:39:48 2008
@@ -1,0 +1,64 @@
+use Test::Tester;
+use Test::More tests=>8;
+use Test::XML::Simple;
+
+my $totally_invalid = <<EOS;
+yarrgh there be no XML here
+EOS
+
+my $broken_xml = <<EOS;
+<imatag> but this isn't good<nomatch>
+EOS
+
+my $valid = <<EOS;
+<CATALOG>
+ <CD>
+ <TITLE>Sacred Love</TITLE>
+ <ARTIST>Sting</ARTIST>
+ <COUNTRY>USA</COUNTRY>
+ <COMPANY>A&M</COMPANY>
+ <PRICE>12.99</PRICE>
+
+ <YEAR>2003</YEAR>
+ </CD>
+</CATALOG>
+EOS
+
+ at results = run_tests(
+ sub {
+ xml_valid(undef, "no xml")
+ }
+ );
+is($results[1]->{diag}, '', "skipped");
+ok(!$results[1]->{ok}, 'failed as expected');
+
+ at results = run_tests(
+ sub {
+ xml_valid($totally_invalid, "invalid xml")
+ }
+ );
+is($results[1]->{diag}, '', "skipped");
+ok(!$results[1]->{ok}, 'failed as expected');
+
+ at results = run_tests(
+ sub {
+ xml_valid($broken_xml, "invalid xml")
+ },
+ {
+ ok=>undef
+ }
+ );
+is($results[1]->{diag}, '', "skipped");
+ok(!$results[1]->{ok}, 'failed as expected');
+
+ at results = run_tests(
+ sub {
+ xml_valid($valid, "good xml")
+ },
+ {
+ ok=>1,
+ }
+ );
+
+is($results[1]->{diag}, '', "ran");
+ok($results[1]->{ok}, 'succeeded as expected');
Added: branches/upstream/libtest-xml-simple-perl/current/t/04node.t
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-xml-simple-perl/current/t/04node.t?rev=15941&op=file
==============================================================================
--- branches/upstream/libtest-xml-simple-perl/current/t/04node.t (added)
+++ branches/upstream/libtest-xml-simple-perl/current/t/04node.t Fri Feb 29 02:39:48 2008
@@ -1,0 +1,54 @@
+use Test::Tester;
+use Test::More tests=>4;
+use Test::XML::Simple;
+
+my $xml = <<EOS;
+<CATALOG>
+ <CD>
+ <TITLE>Sacred Love</TITLE>
+ <ARTIST>Sting</ARTIST>
+ <COUNTRY>USA</COUNTRY>
+ <COMPANY>A&M</COMPANY>
+ <PRICE>12.99</PRICE>
+
+ <YEAR>2003</YEAR>
+ </CD>
+</CATALOG>
+EOS
+
+ at results = run_tests(
+ sub {
+ xml_node($xml, "//ARTIST", "good node")
+ },
+ {
+ ok=>1,
+ }
+ );
+ok($results[1]->{ok}, 'found node');
+
+ at results = run_tests(
+ sub {
+ xml_node($xml, "/CATALOG/ARTIST", "bad path")
+ },
+ );
+ok(!$results[1]->{ok}, 'failed as expected');
+
+ at results = run_tests(
+ sub {
+ xml_node($xml, "/CATALOG/CD/ARTIST", "full path")
+ },
+ {
+ ok=>1,
+ }
+ );
+ok($results[1]->{ok}, 'found full path');
+
+ at results = run_tests(
+ sub {
+ xml_node($xml, "//FORMAT", "bad node")
+ },
+ {
+ ok=>0,
+ }
+ );
+ok(!$results[1]->{ok}, 'failed as expected');
Added: branches/upstream/libtest-xml-simple-perl/current/t/05is.t
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-xml-simple-perl/current/t/05is.t?rev=15941&op=file
==============================================================================
--- branches/upstream/libtest-xml-simple-perl/current/t/05is.t (added)
+++ branches/upstream/libtest-xml-simple-perl/current/t/05is.t Fri Feb 29 02:39:48 2008
@@ -1,0 +1,77 @@
+use Test::Tester;
+use Test::More tests=>6;
+use Test::XML::Simple;
+
+my $xml = <<EOS;
+<CATALOG>
+ <CD>
+ <TITLE>Sacred Love</TITLE>
+ <ARTIST>Sting</ARTIST>
+ <COUNTRY>USA</COUNTRY>
+ <COMPANY>A&M</COMPANY>
+ <PRICE>12.99</PRICE>
+
+ <YEAR>2003</YEAR>
+ </CD>
+</CATALOG>
+EOS
+
+ at results = run_tests(
+ sub {
+ xml_is($xml, "//ARTIST", 'Sting', "good node")
+ },
+ {
+ ok=>1,
+ }
+ );
+ok($results[1]->{ok}, 'found node');
+
+ at results = run_tests(
+ sub {
+ xml_is_long($xml, "//ARTIST", 'Sting', "good node")
+ },
+ {
+ ok=>1,
+ }
+ );
+ok($results[1]->{ok}, 'found node');
+
+ at results = run_tests(
+ sub {
+ xml_is($xml, "/CATALOG/CD/ARTIST", 'Sting', "full path")
+ },
+ {
+ ok=>1,
+ }
+ );
+ok($results[1]->{ok}, 'found path');
+
+ at results = run_tests(
+ sub {
+ xml_is_long($xml, "/CATALOG/CD/ARTIST", 'Sting', "full path")
+ },
+ {
+ ok=>1,
+ }
+ );
+ok($results[1]->{ok}, 'found path');
+
+ at results = run_tests(
+ sub {
+ xml_is($xml, "//ARTIST", 'Weird Al', "good node")
+ },
+ {
+ ok=>0,
+ }
+ );
+ok(!$results[1]->{ok}, 'no node');
+
+ at results = run_tests(
+ sub {
+ xml_is($xml, "/CATALOG/CD/ARTIST", 'Weird Al', "full path")
+ },
+ {
+ ok=>0,
+ }
+ );
+ok(!$results[1]->{ok}, 'no path');
Added: branches/upstream/libtest-xml-simple-perl/current/t/06like.t
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-xml-simple-perl/current/t/06like.t?rev=15941&op=file
==============================================================================
--- branches/upstream/libtest-xml-simple-perl/current/t/06like.t (added)
+++ branches/upstream/libtest-xml-simple-perl/current/t/06like.t Fri Feb 29 02:39:48 2008
@@ -1,0 +1,57 @@
+use Test::Tester;
+use Test::More tests=>4;
+use Test::XML::Simple;
+
+my $xml = <<EOS;
+<CATALOG>
+ <CD>
+ <TITLE>Sacred Love</TITLE>
+ <ARTIST>Sting</ARTIST>
+ <COUNTRY>USA</COUNTRY>
+ <COMPANY>A&M</COMPANY>
+ <PRICE>12.99</PRICE>
+
+ <YEAR>2003</YEAR>
+ </CD>
+</CATALOG>
+EOS
+
+ at results = run_tests(
+ sub {
+ xml_like($xml, "//ARTIST", qr/st/i, "good node")
+ },
+ {
+ ok=>1,
+ }
+ );
+ok($results[1]->{ok}, 'found node');
+
+ at results = run_tests(
+ sub {
+ xml_like($xml, "/CATALOG/CD/ARTIST", qr/ing/, "full path")
+ },
+ {
+ ok=>1,
+ }
+ );
+ok($results[1]->{ok}, 'found path');
+
+ at results = run_tests(
+ sub {
+ xml_like($xml, "//ARTIST", qr/Weird Al/, "good node")
+ },
+ {
+ ok=>0,
+ }
+ );
+ok(!$results[1]->{ok}, 'no node');
+
+ at results = run_tests(
+ sub {
+ xml_like($xml, "/CATALOG/CD/ARTIST", qr/Weird Al/, "full path")
+ },
+ {
+ ok=>0,
+ }
+ );
+ok(!$results[1]->{ok}, 'no path');
Added: branches/upstream/libtest-xml-simple-perl/current/t/07deeply.t
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-xml-simple-perl/current/t/07deeply.t?rev=15941&op=file
==============================================================================
--- branches/upstream/libtest-xml-simple-perl/current/t/07deeply.t (added)
+++ branches/upstream/libtest-xml-simple-perl/current/t/07deeply.t Fri Feb 29 02:39:48 2008
@@ -1,0 +1,41 @@
+use Test::Tester;
+use Test::More tests=>2;
+use Test::XML::Simple;
+
+my $xml = <<EOS;
+<CATALOG>
+ <CD>
+ <TITLE>Sacred Love</TITLE>
+ <ARTIST>Sting</ARTIST>
+ <COUNTRY>USA</COUNTRY>
+ <COMPANY>A&M</COMPANY>
+ <PRICE>12.99</PRICE>
+
+ <YEAR>2003</YEAR>
+ </CD>
+</CATALOG>
+EOS
+
+my $fragment = <<EOS;
+<ARTIST>Sting</ARTIST>
+EOS
+
+my @results = run_tests(
+ sub {
+ xml_is_deeply($xml, "//ARTIST", $fragment, "deep match")
+ },
+ {
+ ok=>1,
+ }
+ );
+ok $results[1]->{ok}, "deep match";
+
+ at results = run_tests(
+ sub {
+ xml_is_deeply($xml, "/", $xml, "identical match")
+ },
+ {
+ ok=>1,
+ }
+ );
+ok $results[1]->{ok}, "identity match";
Added: branches/upstream/libtest-xml-simple-perl/current/t/08attr.t
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-xml-simple-perl/current/t/08attr.t?rev=15941&op=file
==============================================================================
--- branches/upstream/libtest-xml-simple-perl/current/t/08attr.t (added)
+++ branches/upstream/libtest-xml-simple-perl/current/t/08attr.t Fri Feb 29 02:39:48 2008
@@ -1,0 +1,46 @@
+use Test::Tester;
+use Test::More tests=>3;
+use Test::XML::Simple;
+
+my $with_attr = <<EOS;
+<results total="1">this is a result</results>
+EOS
+
+my @results = run_tests(
+ sub {
+ xml_is($with_attr, '//results/@total', "1", "nonempty works")
+ },
+ {
+ ok=>1,
+ }
+ );
+ok($results[1]->{ok}, "nonempty");
+
+my $two_tag = <<EOS;
+<results total="0"></results>
+EOS
+
+ at results = run_tests(
+ sub {
+ xml_is($two_tag, '//results/@total', "0", "two-tag works")
+ },
+ {
+ ok=>1,
+ }
+ );
+
+ok($results[1]->{ok}, "two-tag");
+
+my $collapsed = <<EOS;
+<results total="0"/>
+EOS
+
+ at results = run_tests(
+ sub {
+ xml_is($collapsed, '//results/@total', "0", "collapsed works")
+ },
+ {
+ ok=>1,
+ }
+ );
+ok($results[1]->{ok}, "collapsed");
Added: branches/upstream/libtest-xml-simple-perl/current/t/pod-coverage.t
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-xml-simple-perl/current/t/pod-coverage.t?rev=15941&op=file
==============================================================================
--- branches/upstream/libtest-xml-simple-perl/current/t/pod-coverage.t (added)
+++ branches/upstream/libtest-xml-simple-perl/current/t/pod-coverage.t Fri Feb 29 02:39:48 2008
@@ -1,0 +1,6 @@
+#!perl -Tw
+
+use Test::More;
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
+all_pod_coverage_ok();
Added: branches/upstream/libtest-xml-simple-perl/current/t/pod.t
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-xml-simple-perl/current/t/pod.t?rev=15941&op=file
==============================================================================
--- branches/upstream/libtest-xml-simple-perl/current/t/pod.t (added)
+++ branches/upstream/libtest-xml-simple-perl/current/t/pod.t Fri Feb 29 02:39:48 2008
@@ -1,0 +1,6 @@
+#!perl -Tw
+
+use Test::More;
+eval "use Test::Pod 1.14";
+plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
+all_pod_files_ok();
More information about the Pkg-perl-cvs-commits
mailing list