1. Shlomi Fish
  2. Test-XML-Ordered

Commits

Shlomi Fish  committed 6dc00c4

Fix a typo.

  • Participants
  • Parent commits 56a3ba4
  • Branches default

Comments (0)

Files changed (3)

File Test-XML-Ordered/Changes

View file
+    - Fix a bug where we compared ->name() instead of ->localname().
+        - This caused <db:info /> not to match as <info /> if db: and
+        the default namespace are the same.
+
 0.0.3   Sun  6 Jan 11:09:30 IST 2013
     - Add t/00basic.t to get some diagnosis of the libxml2 versions.
     - Made the minimum required XML::LibXML version 2.0014 to avoid some

File Test-XML-Ordered/lib/Test/XML/Ordered.pm

View file
         }
         elsif ($type == XML_READER_TYPE_ELEMENT())
         {
-            if ($self->_got->name() ne $self->_expected->name())
+            if ($self->_got->localName() ne $self->_expected->localName())
             {
                 return $calc_prob->({param => "element_name"});
             }
     elsif ($status_struct->{param} eq "element_name")
     {
         return
-            "Got name: " . $self->_got->name(). " at " . $self->_got->lineNumber() .
+            "Got name: " . $self->_got->localName(). " at " . $self->_got->lineNumber() .
             " ; " .
-            "Expected name: " . $self->_expected->name() . " at " .$self->_expected->lineNumber();
+            "Expected name: " . $self->_expected->localName() . " at " .$self->_expected->lineNumber();
     }
     elsif ($status_struct->{param} eq "mismatch_ns")
     {

File Test-XML-Ordered/t/xml_compare1.t

View file
 
 use Test::XML::Ordered qw(is_xml_ordered);
 
-use Test::More tests => 2;
+use Test::More tests => 3;
 
-my $xml_source = <<'EOF';
+my @common = (validation => 0, load_ext_dtd => 0, no_network => 1);
+
+{
+    my $xml_source = <<'EOF';
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fic="http://web-cpan.berlios.de/modules/XML-Grammar-Fortune/fiction-xml-0.2/">
 </html>
 EOF
 
-my $final_source = <<'EOF';
+    my $final_source = <<'EOF';
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fic="http://web-cpan.berlios.de/modules/XML-Grammar-Fortune/fiction-xml-0.2/">
 </html>
 EOF
 
-my @common = (validation => 0, load_ext_dtd => 0, no_network => 1);
-# TEST
-is_xml_ordered(
-    [ string => $final_source, @common, ],
-    [ string => $xml_source, @common, ],
-    {},
-    "XMLs are equivalent.",
-);
+    # TEST
+    is_xml_ordered(
+        [ string => $final_source, @common, ],
+        [ string => $xml_source, @common, ],
+        {},
+        "XMLs are equivalent.",
+    );
+
+}
+
+{
+    my $xml_source = <<'EOF';
+<?xml version="1.0" encoding="UTF-8"?>
+<article xmlns="http://docbook.org/ns/docbook" xmlns:fic="http://web-cpan.berlios.de/modules/XML-Grammar-Fortune/fiction-xml-0.2/" xmlns:db="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="index" xml:lang="" version="5.0">
+  <db:info>
+    <db:title>David vs. Goliath - Part I</db:title>
+  </db:info>
+  <section xml:id="top">
+    <db:info>
+      <db:title>The Top Section</db:title>
+    </db:info>
+    <db:para>
+        David and Goliath were standing by each other.
+    </db:para>
+    <db:para>
+        David said unto Goliath: "I will shoot you."
+    </db:para>
+    <section xml:id="goliath">
+      <db:info>
+        <db:title>Goliath\'s Response</db:title>
+      </db:info>
+      <db:para>
+    Goliath was not amused.
+    </db:para>
+      <db:para>
+    He said to David: "Oh, really".
+    </db:para>
+    </section>
+  </section>
+</article>
+EOF
+
+    my $final_source = <<'EOF';
+<?xml version="1.0" encoding="UTF-8"?>
+<article xmlns="http://docbook.org/ns/docbook" xmlns:fic="http://web-cpan.berlios.de/modules/XML-Grammar-Fortune/fiction-xml-0.2/" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="index" xml:lang="" version="5.0">
+  <info>
+    <title>David vs. Goliath - Part I</title>
+  </info>
+  <section xml:id="top">
+    <info>
+      <title>The Top Section</title>
+    </info>
+    <para>
+        David and Goliath were standing by each other.
+    </para>
+    <para>
+        David said unto Goliath: "I will shoot you."
+    </para>
+    <section xml:id="goliath">
+      <info>
+        <title>Goliath\'s Response</title>
+      </info>
+      <para>
+    Goliath was not amused.
+    </para>
+      <para>
+    He said to David: "Oh, really".
+    </para>
+    </section>
+  </section>
+</article>
+EOF
+
+    # TEST
+    is_xml_ordered(
+        [ string => $final_source, @common, ],
+        [ string => $xml_source, @common, ],
+        {},
+        "XMLs are equivalent.",
+    );
+
+}
 
 # TEST
 ok (1, "Finished");