in reply to 0==undef, that's annoying. Is it?

If you were being fussy with your testing you'd turn on fatal warnings in which case the warning you get comparing undef to a number would cause a very obvious failure in your test.

True laziness is hard work

Replies are listed 'Best First'.
Re^2: 0==undef, that's annoying. Is it?
by mascip (Pilgrim) on Jul 16, 2012 at 11:24 UTC

    I hadn't even noticed it produced a warning. Which was at the very start of the TAP output, while the end of the TAP output indicated that all tests passed.

    Test::NoWarnings does the trick, than you :o)
    I tried to turn warnings to fatal with

    use warnings qw(FATAL all);
    as indicated here using FATAL warnings, but it didn't work. It might/could be because of Windows, who doesn't like signals? I'm guessing that FATAL is maybe catching the WARN signal and making it die. But in Windows i found i couldn't catch any signals. It doesn't really matter for me right now : Test::NoWarnings works. Cheers!

    PS : the problem was wider than i thought : 1>undef also returns true. Which means that any cmp_ok($got, '<', $expected) statement runs into the same risk / problem.
    I'll add this to the first post.

      Just as a note for other people :
      Test::NoWarnings does the job, but it means that no warnings will be printed until the end of the tests. Which means that you cannot use Smart::Comments, and cannot use warn() to debug.