Skip Menu |
 

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

Report information
The Basics
Id: 29732
Status: resolved
Priority: 0/
Queue: Test-Differences

People
Owner: Nobody in particular
Requestors: mark.zealey [...] pipex.net
Cc:
AdminCc:

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



Subject: Comparing an array of hashes with non-scalar values is broken
Download (untitled) / with headers
text/plain 1.3k
The following test-case is broken: use strict; use warnings; use Test::More 'no_plan'; use Test::Differences; my $VAR1 = [ { a => 1 }, { b => 1, c => [ ], } ]; my $VAR2 = [ { a => 1 }, { b => 1, c => [ ], } ]; eq_or_diff $VAR1, $VAR2; # Failed test at t/t.t line 26. # +----+----------------------------+----------------------------+ # | Elt|Got |Expected | # +----+----------------------------+----------------------------+ # | 0|a,b,c |a,b,c | # | 1|1,<undef>,<undef> |1,<undef>,<undef> | # * 2|<undef>,1,ARRAY(0x854fb44) |<undef>,1,ARRAY(0x86a5fd8) * # +----+----------------------------+----------------------------+ # Looks like you failed 1 test of 1. So, for some reason it is stringifying the anonymous arrayrefs. This is because there is a typo in the following function which tries to detect if in an array of hashes, the hash is flat (ie it is probably a 'table' format), or if it's a more complicated data structure: sub _isnt_HASH_of_scalars { return 1 if ref ne "HASH"; return scalar grep ref, keys %$_; } Obviously all the keys in the hash are going to be scalars - it should check the values of the hash. Therefore, the line should read: return scalar grep ref, values %$_;
Download (untitled) / with headers
text/plain 1.6k
I'm now a co-maintainer on this and I've fixed this as of 0.48_01. Thanks for the detailed test and fix. And congratulations again on your marriage, Mark :) Cheers, Ovid On Wed Oct 03 07:18:22 2007, mark.zealey@pipex.net wrote: Show quoted text
> The following test-case is broken: > > use strict; > use warnings; > > use Test::More 'no_plan'; > use Test::Differences; > > my $VAR1 = [ > { > a => 1 > }, > { > b => 1, > c => [ ], > } > ]; > my $VAR2 = [ > { > a => 1 > }, > { > b => 1, > c => [ ], > } > ]; > > eq_or_diff $VAR1, $VAR2; > > # Failed test at t/t.t line 26. > # +----+----------------------------+----------------------------+ > # | Elt|Got |Expected | > # +----+----------------------------+----------------------------+ > # | 0|a,b,c |a,b,c | > # | 1|1,<undef>,<undef> |1,<undef>,<undef> | > # * 2|<undef>,1,ARRAY(0x854fb44) |<undef>,1,ARRAY(0x86a5fd8) * > # +----+----------------------------+----------------------------+ > # Looks like you failed 1 test of 1. > > So, for some reason it is stringifying the anonymous arrayrefs. > > This is because there is a typo in the following function which tries to > detect if in an array of hashes, the hash is flat (ie it is probably a > 'table' format), or if it's a more complicated data structure: > > sub _isnt_HASH_of_scalars { > return 1 if ref ne "HASH"; > return scalar grep ref, keys %$_; > } > > Obviously all the keys in the hash are going to be scalars - it should > check the values of the hash. Therefore, the line should read: > > return scalar grep ref, values %$_;
Download (untitled) / with headers
text/plain 203b
Because I accidentally released as a normal version instead of a development version, and because this works in production here at work, I'm marking this resolved. Let me know if it's not. Cheers, Ovid


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.