[Pdx-pm] Testing question

Andy Lester andy at petdance.com
Wed Jan 18 07:57:14 PST 2012

On Jan 18, 2012, at 9:53 AM, Jonathan Duke Leto wrote:

> is($x eq $y, 'blarg')
> this is better:
> cmp_ok($x, 'eq', $y, 'blarg')
> because you will get better error reporting from cmp_ok. It knows that
> you are using 'eq', so it can say "hey, $x != $y", whereas the first
> test will just say "this thing isn't true", which isn't nearly as
> useful.

ok( $x eq $y, 'blarg' ) isn't informative.

is( $x, $y, 'blarg' ) tells you what's different.

cmp_ok( $x, 'eq', $y, 'blarg' ) is no more informative than the is() call.  cmp_ok should be used only if you want to compare using something other than 'eq'.


Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/pdx-pm-list/attachments/20120118/eeb79706/attachment.html>

More information about the Pdx-pm-list mailing list