Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Test-Differences CPAN distribution.

Report information
The Basics
Id: 95206
Status: open
Priority: 0/
Queue: Test-Differences

People
Owner: Nobody in particular
Requestors: nyaapa [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: bug when comparing numerical hash values [again]
Date: Wed, 30 Apr 2014 16:44:36 +0400
To: bug-Test-Differences [...] rt.cpan.org
From: nyaapa <nyaapa [...] gmail.com>
nyaapa@nyaapa:~$ perl -e 'use Test::More; use Test::Differences qw(eq_or_diff); diag $Test::Differences::VERSION; eq_or_diff { a => { a => 1 }}, { a=> { a => "1"}}, "abc"' # 0.61 not ok 1 - abc # Failed test 'abc' # at -e line 1. # +----+------------+--------------+ # | Elt|Got |Expected | # +----+------------+--------------+ # | 0|{ |{ | # | 1| a => { | a => { | # * 2| a => 1 | a => '1' * # | 3| } | } | # | 4|} |} | # +----+------------+--------------+ # Tests were run but no plan was declared and done_testing() was not seen. nyaapa@nyaapa:~$ perl -e 'use Test::More; use Test::Differences qw(eq_or_diff); diag $Test::Differences::VERSION; eq_or_diff { a => 1 }, { a=> "1"}, "abc"' # 0.61 ok 1 - abc # Tests were run but no plan was declared and done_testing() was not seen. -- Kindest Regards, Arseny Krasikov
On Wed Apr 30 08:44:48 2014, nyaapa@gmail.com wrote: Show quoted text
> nyaapa@nyaapa:~$ perl -e 'use Test::More; use > Test::Differences qw(eq_or_diff); diag $Test::Differences::VERSION; > eq_or_diff { a => { a => 1 }}, { a=> { a => "1"}}, "abc"' > # 0.61 > not ok 1 - abc > # Failed test 'abc' > # at -e line 1. > # +----+------------+--------------+ > # | Elt|Got |Expected | > # +----+------------+--------------+ > # | 0|{ |{ | > # | 1| a => { | a => { | > # * 2| a => 1 | a => '1' * > # | 3| } | } | > # | 4|} |} | > # +----+------------+--------------+ > # Tests were run but no plan was declared and done_testing() was not seen. > nyaapa@nyaapa:~$ perl -e 'use Test::More; use > Test::Differences qw(eq_or_diff); diag $Test::Differences::VERSION; > eq_or_diff { a => 1 }, { a=> "1"}, "abc"' > # 0.61 > ok 1 - abc > # Tests were run but no plan was declared and done_testing() was not seen. >
On 2014-04-30 08:44:48, nyaapa@gmail.com wrote: Show quoted text
> nyaapa@nyaapa:~$ perl -e 'use Test::More; use > Test::Differences qw(eq_or_diff); diag $Test::Differences::VERSION; > eq_or_diff { a => { a => 1 }}, { a=> { a => "1"}}, "abc"' > # 0.61 > not ok 1 - abc > # Failed test 'abc' > # at -e line 1. > # +----+------------+--------------+ > # | Elt|Got |Expected | > # +----+------------+--------------+ > # | 0|{ |{ | > # | 1| a => { | a => { | > # * 2| a => 1 | a => '1' * > # | 3| } | } | > # | 4|} |} | > # +----+------------+--------------+ > # Tests were run but no plan was declared and done_testing() was not seen. > nyaapa@nyaapa:~$ perl -e 'use Test::More; use > Test::Differences qw(eq_or_diff); diag $Test::Differences::VERSION; > eq_or_diff { a => 1 }, { a=> "1"}, "abc"' > # 0.61 > ok 1 - abc > # Tests were run but no plan was declared and done_testing() was not seen. >
If you need a workaround, then you can use: local $Data::Dumper::Useperl = 1; before calling eq_or_diff. Data::Dumper behaves slightly differently in XS and PurePerl mode. In XS mode (which is the default) scalar values are dumped according to the internal flag. If a scalar value containing an number is flagged as a PV, then it is dumped as a string. Outside of XS it's not possible to see the internal flag (well, at least it's not so easy), so a simple regexp is used to determine if a scalar value can be dumped as an integer or not. Maybe it would be better if this behavior could be configurable in Test::Differences. I can think of situations where one would like to see even the differences of the internal representation, but most of the time a user would expect 1 and "1" equal, so this should probably be the default. Regards, Slaven