Front page | perl.module-authors |
Postings from January 2010
Re: Comparing hashes
January 19, 2010 06:03
Re: Comparing hashes
Message ID: F8A3D0EC-E83E-4831-BC3D-7752CD220002@animalhead.com
Bruce Gray's reply indicates that your routine, that constructs the
array that you were comparing to the "gold" one, was populating the
array by using each(%hash). Since the order in which entries are
returned is not consistent, you can't use a "known correct"
It seems he even sent you a patch to use 'for (sort %hash)' instead.
If all forum responders were this helpful, all known computing
problems would be solved by now :-)
On Jan 18, 2010, at 8:01 AM, Geoffrey Leach wrote:
> Hmmmm ... that bruse on my forehead is getting larger ... :-)
> Thanks for the reply. And my appologies for getting confused about my
> own code.
> So let me restate the problem.
> In order to verify the correctness of internal data structures, the
> test in question:
> is_deeply( Getopt::Auto::_get_spec_ref(),
> \@exspec, 'Spec gets built correctly' );
> uses is_deeply() to compare a 'gold' version of the array @exspec with
> the constructed instance, obtained by the (internal) function
> This succeeds (so far) on 5.10.x and all but one (so far) 5.8.x. I
> thinks there's a success on 5.11.x as well.
> What I meant by "having dealt with the problem" was that the problem
> exposed by the failing test, namely:
> Failed test 'Spec gets built correctly'
> at t/03-options_text.t line 107.
> Structures begin differing at:
> $got-> = '--foo'
> $expected-> = '--tar'
> I my testing (5.10.x), when I saw a similar problem, I resolved it
> by organizing my 'gold' structure to match the computed version.
> Having gotten everything to work for 5.10.x, I was assuming that
> failures in 5.6.x had something to do with the internal organiation of
> the data structure (hence my reference to "unsupported feature"). The
> 5.8.1 failure came along later.
> Looks like I need to have another look at the generation.
> Thanks for the help.
> On 01/17/2010 05:33:33 PM, firstname.lastname@example.org wrote:
>> From a quick glance at the first error, it involves using
>> is_deeply to compare arrays of arrays, not hashes. So
>> it's not clear "how Perl organizes the hash" gets involved.
>> You also have a failure on perl 5.8.1 that looks very similar,
>> so 5.6.2 is less of a suspect.
>> You need to explain certain aspects of the problem more
>> completely to allow someone to help you, particularly:
>> "what's generated at run time: it comes out different"
>> "dealt with this problem" (what problem?)
>> "getting it just right" (what's it?)
>> "using an unsupported feature" (which feature is that?)
>> On Jan 17, 2010, at 4:31 PM, Geoffrey Leach wrote:
>>> I'm dealing with an error report from cpantesters for Getopt::Auto.
>>> The problem arrises out of using Test::More::is_deeply to compare a
>>> hash with what's generated at run time: it comes out different.
>>> I've delt with this problem in my own testing, and have spent some
>>> getting it 'just right'. I suspect the problem arrises out of how
>>> organizes the hash. The version with the problem is perl-5.6.2.
>>> versions pass. Given that I'm using an unsupported feature, things
>>> well come unglued in the future.
>>> So, are there any suggestions? Test::Deep? 'use Perl 5.8.0'?