hi all :) so, as a standard practice, I start with
use_ok($class); as the first test in each file, the idea being that if the class doesn't compile I shouldn't care about the results of the rest of the test - I know immediately that subsequent failures are because I introduced a typo or something. rationale agreement aside, because most of the time the typos are introduced in the subroutine I'm testing I get a bunch of failures later on in the test file (which I ignore). but yesterday a fellow coder introduced a typo at the package level, something equivalent to this: package Foo; use strict; use warnings FATAL => qw(all); foo; # blows up sub bar { return "inside bar"; } simple enough. I was, however, met with surprise when my test for bar() came back ok: $ perl bar.t 1..2 not ok 1 - use Foo; # Failed test 'use Foo;' # in bar.t at line 5. # Tried to use 'Foo'. # Error: Bareword "foo" not allowed while "strict subs" in use... # Compilation failed in require at (eval 3) line 2. # BEGIN failed--compilation aborted at bar.t line 5. ok 2 - bar() called successfully # Looks like you failed 1 test of 2. so, the compile test failed, but bar() could still be called and, in fact, even executed successfully. anyway, I'm not suggesting this is a bug. I might be suggesting that use_ok() should change somewhat. but, more than all that, I figured folks would just find it interesting if it's something y'all didn't already know. --Geoff