Commits

Shlomi Fish  committed ed97737

NodeList: add missing string comparison operator.

https://rt.cpan.org/Ticket/Display.html?id=57737 - resolving this.

  • Participants
  • Parent commits 06d3fda

Comments (0)

Files changed (3)

         - https://rt.cpan.org/Ticket/Display.html?id=57652 .
     - Add an external entity resolver (for XSLT/etc.):
         - Fixing https://rt.cpan.org/Ticket/Display.html?id=69166 .
+    - Add the missing string comparison overload in
+    lib/XML/LibXML/NodeList.pm :
+        - https://rt.cpan.org/Ticket/Display.html?id=57737
+        - Thanks to MSCHWERN .
     
 1.76            Thu Jun 30 20:58:46 IDT 2011
     - Cleaned up t/28new_callbacks_multiple.t - convert to a Counter

File lib/XML/LibXML/NodeList.pm

 use overload 
         '""' => \&to_literal,
         'bool' => \&to_boolean,
+        'cmp' => sub {
+            my($aa, $bb, $order) = @_;
+            return ($order ? ("$bb" cmp "$aa") : ("$aa" cmp "$bb"));
+        },
         ;
 
 sub new {

File t/15nodelist.t

 use strict;
 use warnings;
 
-use Test::More tests => 11;
+use Test::More tests => 13;
 
 use XML::LibXML;
 use IO::Handle;
 # TEST
 is($nodelist->to_literal, "OKNOT OK", ' TODO : Add test name');
 
+{
+    my $other_nodelist = $dom->findnodes('//BBB');
+    while ($other_nodelist->to_literal() !~ m/\ANOT OK/)
+    {
+        $other_nodelist->shift();
+    }
+
+    # This is a test for:
+    # https://rt.cpan.org/Ticket/Display.html?id=57737
+
+    # TEST
+    ok (scalar(($other_nodelist) lt ($nodelist)), "Comparison is OK.");
+
+    # TEST
+    ok (scalar(($nodelist) gt ($other_nodelist)), "Comparison is OK.");
+}
+
 # TEST
 is($dom->findvalue("//BBB"), "OKNOT OK", ' TODO : Add test name');