develooper Front page | perl.perl5.porters | Postings from November 2008

[ANNOUNCE] Test::More/Builder/Simple 0.86 (cmp_ok() fixage warning)

Michael G Schwern
November 9, 2008 01:23
[ANNOUNCE] Test::More/Builder/Simple 0.86 (cmp_ok() fixage warning)
Message ID:
or a CPAN near you!

This release mostly deals with fixing a long standing problem with cmp_ok()
and overloaded objects.  I expect this to cause some fixage.

Previously, overloaded objects would have their overloading stripped, turning
them into normal numbers or strings, before comparison.  Therefore this...

	cmp_ok $left, '==', $right;

was really this:

	ok $left+0 == $right+0;

If $left or $right had == overloaded it was not getting called.  This is
important for some overloaded objects.  The most dramatic being DateTime which
cannot be numified or added to:

  Cannot add 0 to a DateTime object (DateTime=HASH(0x191b2e0)).
   Only a DateTime::Duration object can  be added to a DateTime object.

This has been fixed.  The proper overloaded comparison is now done with no

Additionally... warnings from cmp_ok() will now come from "cmp_ok" and not try
to pretend they come from the caller.  This should help clear up expectations
about how lexical pragmas (such as "no warnings") will work.  But the caller's
file and line will still be in the report.

    Use of uninitialized value $got in numeric eq (==) at cmp_ok [from foo.t
line 54] line 1.

0.86  Sun Nov  9 01:09:05 PST 2008
    Same as 0.85_01

0.85_01  Thu Oct 23 18:57:38 PDT 2008
    New Features
    * cmp_ok() now displays the error if the comparison throws one.
      For example, broken overloaded objects.

    Bug Fixes
    * cmp_ok() no longer stringifies or numifies its arguments before comparing.
      This makes cmp_ok() properly test overloaded ops.
      [ 24186] [ 16]
    * diag() properly escapes blank lines.

    Feature Changes
    * cmp_ok() now reports warnings and errors as coming from inside cmp_ok,
      as well as reporting the caller's file and line.  This let's the user
      know where cmp_ok() was called from while reminding them that it is
      being run in a different context.

    * Dependency on ExtUtils::MakeMaker 6.27 only on Windows otherwise the
      nested tests won't run.

There will be snacks. Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About