No other warnings Test::FailWarnings



examples/test-warn/t/fibonacci_failwarnings.t
use strict;
use warnings;

use Test::More;
use Test::FailWarnings;
use Test::Warn;

use MyTools qw(fibo);

subtest positive_2 => sub {
    my $result = fibo(2);
    is($result, 1, 'fibonacci on 2');
};

subtest negative => sub {
    my $result;
    warning_is {$result = fibo(-1)} "Given number must be > 0",
        'warning when called with -1';
    is($result, undef, 'fibonacci on -1 returns undef');
};

subtest positive_4 => sub {
    my $result = fibo(4);
    is($result, 3, 'fibonacci on 4');
};

subtest positive_6 => sub {
    my $result = fibo(6);
    is($result, 8, 'fibonacci on 6');
};

done_testing;

prove -lv t/fibonacci_failwarnings.t


t/fibonacci_failwarnings.t .. 
# Subtest: positive_2
    ok 1 - fibonacci on 2
    1..1
ok 1 - positive_2
# Subtest: negative
    ok 1 - warning when called with -1
    ok 2 - fibonacci on -1 returns undef
    1..2
ok 2 - negative
# Subtest: positive_4
    ok 1 - fibonacci on 4
    1..1
ok 3 - positive_4
# Subtest: positive_6
    ok 1 - fibonacci on 6
    1..1
ok 4 - positive_6
1..4
ok
All tests successful.
Files=1, Tests=4,  0 wallclock secs ( 0.02 usr  0.00 sys +  0.17 cusr  0.01 csys =  0.20 CPU)
Result: PASS