On Sat, Jul 02, 2005 at 08:40:48PM +0100, Nicholas Clark wrote:
> > something like:
> > 
> >     like( $foo, qr/.../ );
> > 
> > and:
> > 
> >     cmp_ok( $foo, 'eq', $bar );
> > 
> > warning about $foo being undefined?  Especially since the test diagnostics
> > will let you know about what was undef.
> 
> I'm not sure. For the specific example of cmp_ok with 'eq', then because
> the programmer has chosen that over is(), it seems fair that he/she made
> an explicit choice that $foo being undef was an acceptable match for $bar
> being an empty string. (Not so sure about the other 13 comparison operators)

Yeah, 'eq' was a bad choice as its unlikely to be used.  Something like:

        cmp_ok( $foo, '>=', $bar );

In which case I think that yes, you want a normal undef warning because...

        cmp_ok( 2, '>=', undef );

passes.


> I think I'd prefer like to fail (distinct from warning) if $foo is undef,
> given that the expected regexp may well intentionally match an empty string.

No, I'm not going to try an second guess the intention of the tester.  If
they craft a match which matches against undef then the test passes.  But
a warning serves its purpose of "hey, are you SURE you wanted this?" and
they can choose to supress it.

Now all I have to do is figure a clever way to supress all but uninit
warnings without using warnings.pm.


-- 
Michael G Schwern     [EMAIL PROTECTED]     http://www.pobox.com/~schwern
Ahh email, my old friend.  Do you know that revenge is a dish that is best 
served cold?  And it is very cold on the Internet!

Reply via email to