Fergal Daly wrote:
>>   #!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,

The important thing is not just testing use_ok(), but testing use_ok() when
the -c Perl flag is set (think B::Deparse or perlcc) and HARNESS_ACTIVE is
true to test that bug.  Normally this would require a system() call, but you
can cheat.

{
    local $ENV{HARNESS_ACTIVE} = 1;
    local $^C = 1;

    require Test::More;
    Test::More->import(tests => 1);

    use_ok("Fcntl", "Pie")
}


-- 
If at first you don't succeed--you fail.
        -- "Portal" demo

Reply via email to