Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Solution: test sum

use strict;
use warnings;

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

use lib 'lib';
use MyTools;



{
    my $result;
    TODO: {
        local $TODO = 'fix warnings';
        warning_is {$result = sum()} undef, 'no warning in empty sum';
    }
    is($result, 0, 'result is ok');
}


use strict;
use warnings;

use Test::More tests => 3;
use Test::Exception;

use lib 'lib';
use MyTools;


{
    my $result = fibonacci(3);
    is($result, 2, 'fibonacci on 3');
}
{
    dies_ok {fibonacci()} 'expecting to die';
}
{
    my $result = fibonacci(4);
    is($result, 3, 'fibonacci on 4');
}