- Test::NoWarnings
No other warnings using Test::NoWarnings
examples/test-warn/t/fibonacci_no_warnings.t
use strict; use warnings; use Test::More tests => 4 + 1; use Test::NoWarnings; 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'); };
prove -lv t/fibonacci_no_warnings.t
t/fibonacci_no_warnings.t .. 1..5 # 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 ok 5 - no warnings ok All tests successful. Files=1, Tests=5, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.17 cusr 0.01 csys = 0.20 CPU) Result: PASS