Subject: | is_xpath doesn't compare numbers correctly |
Distribution name and version: Test-XML-0.06
Perl version: v5.8.6
Operating System vendor and version: FreeBSD 5.3-RELEASE
Mininal test case:
is_xpath( '<foo>bar</foo>', 'count(/foo)', 1 );
Output:
not ok 1
# Failed test (./test.pl at line 6)
# got: '1'
# expected: '1'
# evaluating: count(/foo)
# against: <foo>bar</foo>
Normally when using is_xpath the got value evaluates to an XML::XPath::Literal which can be compared with the expected string. In this case it evaluates to an XML::XPath::Number.
Here is some Test::Builder code that demonstrates the problem:
my $Test = Test::Builder->new;
$Test->is_eq(XML::XPath::Literal->new("bar"), "bar"); # PASS
$Test->is_eq(XML::XPath::Number->new(1), 1); # FAIL
$Test->is_num(XML::XPath::Number->new(1), 1); # PASS
So maybe you need to run $Test->is_eq if you get an XML::XPath::Literal and run $Test->is_num if you get an XML::XPath::Number.
I've attached a patch with a Test case and a fix.
Message body not shown because it is not plain text.