Skip Menu | You are currently an anonymous guest. | Login | Return to Main | About rt.cpan.org
 

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

X Report information
Id: 29732
Status: resolved
Left: 0 min
Priority: 0/0
Queue: Test-Differences

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

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



X History Display mode: Brief headersFull headers
#   Wed Oct 03 07:18:22 2007 mark.zealey[...]pipex.net - Ticket created  
Subject: Comparing an array of hashes with non-scalar values is broken
[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 %$_;

#   Wed Jul 30 06:07:22 2008 OVID - Correspondence added  
[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:
> 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 %$_;



#   Wed Jul 30 06:07:26 2008 RT_System - Status changed from 'new' to 'open'  
#   Thu Jul 31 05:20:05 2008 OVID - Correspondence added  
[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
#   Thu Jul 31 05:20:09 2008 OVID - Status changed from 'open' to 'resolved'