If we can test our code for specific warnings we should also test that in other places there are no warnings.

examples/perl/t/fibonacci_test_warn.t
use strict;
use warnings;

use Test::More tests => 6;
use Test::Warn;

use lib 'lib';
use MyTools;


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

{
    my $result;
    warning_is {$result = fibonacci(4)} undef, 'no warning here';
    is($result, 3, 'fibonacci on 4 returns 3');
}

{
    my $result;
    warning_is {$result = fibonacci(6)} undef, 'no warning here';
    is($result, 8, 'fibonacci on 6 returns 8');
}


Output:

examples/perl/t/fibonacci_test_warn.out
1..6
ok 1 - warning when called with -1
ok 2 - fibonacci on -1 returns 0
ok 3 - no warning here
ok 4 - fibonacci on 4 returns 3
ok 5 - no warning here
ok 6 - fibonacci on 6 returns 8