2008/9/19 brian d foy <[EMAIL PROTECTED]>: > In article <[EMAIL PROTECTED]>, Nicholas Clark > <[EMAIL PROTECTED]> wrote: > >> But it seems that this bug is only fixed as a side effect of that change, and >> it's not actually tested for. What's the best way to write a test that fits >> within the current frameworks to prevent any regression? >> It's not obvious to me how to make use_ok() test for failure. > > Are you looking for Test::Builder::Tester? > > #!perl > > use Test::More tests=>1; > use Test::Builder::Tester; > > test_out('not ok 1 - use Fcntl;'); > test_fail(+1); > use_ok 'Fcntl', 'Pie'; > test_test( "Fails for bad export"); > __END__ >
alternatively use Test::Tester; use Test::More tests => 1; check_test(sub { use_ok('Fcntl', 'Pie') }, {ok => 0, name => "use Fcntl;"}, "Fails for bad export") which is approximately as verbose but doesn't require you to track test numbers or worry about line numbers (all handled automatically) and allows you run blocks of code containing multiple tests, F