[tpm] Riddle me this ...

James E Keenan jkeen at verizon.net
Thu Dec 27 18:25:37 PST 2012


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.

This is adapted from tests 4 and 5 in the Perl 5 core distribution's 
t/op/not.t.  Although that program uses t/test.pl instead of Test::More 
(as above), the outcome is the same.  (If you have a checkout and build 
of blead, say: cd t; ./perl harness -v op/not.t)

There's something strange happening with operator precedence here.  Can 
anyone suss this out?

Thank you very much.
Jim Keenan


More information about the toronto-pm mailing list