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: 59210
Status: rejected
Priority: 0/
Queue: Test-Differences

People
Owner: Nobody in particular
Requestors: ether [...] cpan.org
Cc:
AdminCc:

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



Subject: Bad code for _isnt_ARRAY_of_scalars, _isnt_HASH_of_scalars
Download (untitled) / with headers
text/plain 801b
There are some errors in the definitions for _isnt_ARRAY_of_scalars() and _isnt_HASH_of_scalars() which lead to "interesting" results... I discovered this when comparing arrays of objects which have stringification overloads... The code in 0.5 is: sub _isnt_ARRAY_of_scalars { return 1 if ref ne "ARRAY"; return scalar grep ref, @$_; } sub _isnt_HASH_of_scalars { return 1 if ref ne "HASH"; return scalar grep ref, values %$_; } When it should actually be: sub _isnt_ARRAY_of_scalars { return 1 if ref $_[0] ne "ARRAY"; return scalar grep ref, @$_{[0]}; } sub _isnt_HASH_of_scalars { return 1 if ref $_[0] ne "HASH"; return scalar grep { ref } values %{$_[0]}; } Note that $_ is not normally defined in the body of a function -- instead of $_ you should use $_[0].
Download (untitled) / with headers
text/plain 1.2k
On Thu Jul 08 18:30:17 2010, bitcard@froods.org wrote: Show quoted text
> There are some errors in the definitions for _isnt_ARRAY_of_scalars() > and _isnt_HASH_of_scalars() which lead to "interesting" results... I > discovered this when comparing arrays of objects which have > stringification overloads... > > The code in 0.5 is: > > sub _isnt_ARRAY_of_scalars { > return 1 if ref ne "ARRAY"; > return scalar grep ref, @$_; > } > sub _isnt_HASH_of_scalars { > return 1 if ref ne "HASH"; > return scalar grep ref, values %$_; > } > > When it should actually be: > sub _isnt_ARRAY_of_scalars { > return 1 if ref $_[0] ne "ARRAY"; > return scalar grep ref, @$_{[0]}; > } > > sub _isnt_HASH_of_scalars { > return 1 if ref $_[0] ne "HASH"; > return scalar grep { ref } values %{$_[0]}; > } > > Note that $_ is not normally defined in the body of a function -- > instead of $_ you should use $_[0].
Hi, thanks for the bug report. I'm sorry I've gotten to this so late. I'm actually the maintainer of this code and not the author, so when I saw that, I was surprised to see it written like that. However, the original author originally called this after this: local $_ = shift @_; That allows the above functions to work, even though it looks strange and this is not, in fact, a bug. 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.