Commits

Anonymous committed a222d65

Added another example.

  • Participants
  • Parent commits ee050bd

Comments (0)

Files changed (3)

File XML-Grammar-Fortune/module/MANIFEST

 README
 t/00-load.t
 t/data/xml/irc-conversation-1.xml
+t/data/xml/irc-conversation-2-with-slash-me.xml
 t/pod-coverage.t
 t/pod.t
 t/xml-validate.t

File XML-Grammar-Fortune/module/t/data/xml/irc-conversation-2-with-slash-me.xml

+<?xml version="1.0" encoding="utf-8"?>
+<collection>
+    <head />
+    <list>
+        <fortune id="I-need-to-get-a-life">
+            <irc>
+                <body>
+                    <saying who="rindolf">sussman: for the record, I think the 
+                        build system is the ultimate proof that python code 
+                        can be as bad as Perl one.</saying>
+                    <me_is who="clkao">giggles</me_is>
+                    <saying who="jackr">hehe</saying>
+                    <saying who="rindolf">hopes he's not starting a flamewar</saying>
+                    <saying who="clkao">btw, freebsd svn port maintainer was 
+                        complaining about unable to do --with-swig specifying 
+                        only perl or pythong bindings to build..</saying>
+
+                    <me_is who="cmpilato">notes that the topic of this channel 
+                        is Subversion.</me_is>
+                    <saying who="clkao">(so he refused to include the option 
+                        for building either bindings in the port!)</saying>
+                    <saying who="rindolf">I once saw a perl5 code written in 
+                        perl4 style. Now that was hideous.</saying>
+                    <saying who="fitz">complicated != bad</saying>
+                    <saying who="fitz">"Building is complicated--that's why 
+                        build systems are complicated." --kfogel</saying>
+                </body>
+                <info>
+                    <channel>#svn</channel>
+                    <network>Freenode</network>
+                    <tagline>Discussing the Subversion Build System</tagline>
+                </info>
+            </irc>
+        </fortune>
+    </list>
+</collection>

File XML-Grammar-Fortune/module/t/xml-validate.t

 use strict;
 use warnings;
 
-use Test::More tests => 1;                      # last test to print
+use Test::More tests => 2;                      # last test to print
 
 use XML::LibXML;
 
-my $doc = XML::LibXML->new->parse_file("./t/data/xml/irc-conversation-1.xml");
+my @inputs = (qw(
+        irc-conversation-1
+        irc-conversation-2-with-slash-me
+    ));
 
 my $rngschema = XML::LibXML::RelaxNG->new(
-    location => "./extradata/fortune-xml.rng" 
-);
+        location => "./extradata/fortune-xml.rng" 
+    );
 
-my $code;
-$code = $rngschema->validate($doc);
 
-# TEST
-ok ((defined($code) && ($code == 0)),
-    "The validation succeeded.") ||
-    diag("\$@ == $@");
+# TEST:$num_tests=2
 
+foreach my $fn_base (@inputs)
+{
+    my $doc = XML::LibXML->new->parse_file("./t/data/xml/$fn_base.xml");
+
+    my $code;
+    $code = $rngschema->validate($doc);
+
+    # TEST*$num_tests
+    ok ((defined($code) && ($code == 0)),
+        "The validation succeeded.") ||
+        diag("\$@ == $@");
+
+}