develooper Front page | perl.perl5.porters | Postings from May 2010

Pending Test::More fixage - DateTime and string overload users takenote

Thread Next
Michael G Schwern
May 19, 2010 16:55
Pending Test::More fixage - DateTime and string overload users takenote
Message ID:
Test::Simple/More/Builder 0.95_02 has just been released.  I'm proud to say
that I had very little to do with it.  All the commits are the work of Nick
Clayton and him not being afraid to flex his commit bit. :)

0.95_01 introduced fixage [1] (my fault, not Nick's) when testing overloaded
objects.  is(), and probably other functions, no longer stringify their
arguments before comparing.  It was a long standing bug that they did.  This
means string overloaded objects will now use their eq method to compare rather
than "".

For a well written overloaded objects this should have no effect.
Unfortunately, its very easy to forget to implement a comparison function or
turn on fallback.  DateTime objects prior to 0.54 did this.

    use Test::More;
    use DateTime;

    my $date1 = DateTime->new( year => 2010 );
    my $date2 = DateTime->new( year => 2010 );

    is( $date1, $date2 );


The above code will fail with DateTime prior to 0.54 and Test::More after (but
not including) 0.94.  Any code which uses DateTime objects should verify
against the Test::More alpha and upgrade DateTime as necessary.  Authors of
string overloaded classes should also verify their implementations and unless
you have a good reason not to, turn on fallback.

For compatibility with older versions of DateTime and Test::More, you should
quote DateTime objects before comparing with is().

    is( "$date1", "$date2" );

CPAN Testers, please load your smokers with Test::More 0.95_02, compare the
results with Test::More 0.94 and report any differences in test results to
their respective authors.  I would like to see a summary of the differences as
well so I know the scope of the fixage.

Thank you and sorry for the inconvenience.

[1] Bug fixes which will reveal failing tests that accidentally pass.


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About