[tpm] Riddle me this ...

Olaf Alders olaf.alders at gmail.com
Thu Dec 27 19:08:55 PST 2012


On 2012-12-27, at 9:25 PM, James E Keenan wrote:

> Shouldn't the outcome of a test be independent of whether the test has a description/name/label or not?
> 
> First, try this at the command line:
> 
> $>  perl -MTest::More -E 'is(! 1, not 1);is(! 0, not 0);done_testing;'
> 
> You should get:
> 
> ok 1
> ok 2
> 1..2
> 
> ... which is what I would expect.
> 
> 
> But now, try this, which simply adds a description to each test:
> 
> $ perl -MTest::More -E 'is(! 1, not 1, "test1");is(! 0, not 0, "test2");done_testing;'
> ok 1
> not ok 2
> #   Failed test at -e line 1.
> #          got: '1'
> #     expected: ''
> 1..2
> # Looks like you failed 1 test of 2.
> 
> Neither test prints its description, and the second test now fails.

Hi Jim,

I think Liam has answered the question, but I wanted to point out from the Test::More docs that (quoting here) "You are encouraged to use is() and isnt() over ok() where possible, however do not be tempted to use them to find out if something is true or false!"

Best,

Olaf
--
Olaf Alders
olaf.alders at gmail.com

http://www.wundercounter.com
http://twitter.com/wundercounter

866 503 2204 (Toll free - North America)
416 944 8306 (direct)



More information about the toronto-pm mailing list