plan tests, no_testing, done_testing



examples/test-plan/lib/Fibonacci.pm
package Fibonacci;
use strict;
use warnings;

use Exporter qw(import);
our @EXPORT_OK = qw(fibo);

sub fibo {
    my ($n) = @_;
    return $n if $n == 0 or $n == 1;

    #exit if $n == 4;

    my @fib = (0, 1);
    for (2..$n) {
        push @fib, $fib[-1] + shift @fib;
    }
    return $fib[-1];
}


1;

examples/test-plan/t/plan_tests.t
use strict;
use warnings;

use Fibonacci qw(fibo);

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

is fibo(1), 1;
is fibo(2), 1;
is fibo(3), 2;
is fibo(4), 3;
is fibo(5), 5;
is fibo(6), 8;

examples/test-plan/t/no_plan.t
use strict;
use warnings;

use Fibonacci qw(fibo);

use Test::More 'no_plan';

is fibo(1), 1;
is fibo(2), 1;
is fibo(3), 2;
is fibo(4), 3;
is fibo(5), 5;
is fibo(6), 8;

examples/test-plan/t/done_testing.t
use strict;
use warnings;

use Fibonacci qw(fibo);

use Test::More;

is fibo(1), 1;
is fibo(2), 1;
is fibo(3), 2;
is fibo(4), 3;
is fibo(5), 5;
is fibo(6), 8;

done_testing;