On Sat, Feb 14, 2009 at 12:57:45PM +0200, Gabor Szabo wrote:
> On Thu, Feb 12, 2009 at 3:18 PM, Nicholas Clark <[email protected]> wrote:
> > I find
> >
> > isnt($foo, undef);
> >
> > useful as it gives better failure diagnostics than
> >
> > ok(defined $foo);
> >
>
> Wouldn't it be better to write this
>
> is_defined($foo);
>
> Which, on failure would print
> # got: undef
> # expected: anything else
>
> as it does your example.
>
> Schwern, can this be added to Test::More ?
Assuming that isnt() isn't going to be removed from Test::More, I don't see
this as a good idea. Your proposed is_defined($foo) is the same amount of
typing as isnt($foo, undef), gives no better diagnostics, is no clearer in
its intent than isnt($foo, undef), and increases the complexity of the
interface to Test::More by 1 function. It feels like:
Although the Perl Slogan is There's More Than One Way to Do It, I
hesitate to make 10 ways to do something. :-)
http://groups.google.com/group/comp.lang.perl/msg/b7b1650e90b89c0b
Nicholas Clark