[Pdx-pm] Testing question

Michael G Schwern schwern at pobox.com
Sun Jan 22 14:18:21 PST 2012


On 2012.1.18 7:57 AM, Andy Lester wrote:
> 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'.

...or if you REALLY want to make sure 'eq' is used for the test.  Usually this
is only important when testing operator overloading.

is() doesn't always use 'eq'.  For example, it will consider "" and undef
different.

    is( "", undef );            # fail
    cmp_ok( "", 'eq', undef );  # pass

is()'s extra logic is usually what you want.


-- 
170. Not allowed to "defect" to OPFOR during training missions.
    -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army
           http://skippyslist.com/list/


More information about the Pdx-pm-list mailing list