Front page | perl.module-authors |
Postings from January 2010
Re: Comparing hashes
From: Geoffrey Leach
January 18, 2010 13:48
Re: Comparing hashes
Message ID: email@example.com
Amen to that! He even corrected the tests!
On 01/18/2010 09:17:01 AM, firstname.lastname@example.org wrote:
> 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
> > 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
> > the constructed instance, obtained by the (internal) function
> > Getopt::Auto::_get_spec_ref().
> > 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
> > 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
> > the data structure (hence my reference to "unsupported feature").
> > 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, email@example.com 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
> >>> The problem arrises out of using Test::More::is_deeply to compare
> >>> 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
> >>> time
> >>> getting it 'just right'. I suspect the problem arrises out of how
> >> Perl
> >>> organizes the hash. The version with the problem is perl-5.6.2.
> >> Later
> >>> versions pass. Given that I'm using an unsupported feature,
> >> may
> >>> well come unglued in the future.
> >>> So, are there any suggestions? Test::Deep? 'use Perl 5.8.0'?
> >>> Thanks.