package MyMath;
use strict;
use warnings;
use Exporter qw(import);
our @EXPORT_OK = qw(add div fibo abs);
our $VERSION = '0.02';
=head1 NAME
MyMath - some tools to show test coverage
=head1 SYNOPSIS
Short example
=head2 add
Some docs
=cut
sub add {
return $_[0] + $_[1];
}
sub abs {
my ($num) = @_;
if ($num < 0) {
return -$num;
}
return $num;
}
sub fibo {
my ($n) = @_;
return $n if $n == 0 or $n == 1;
my @fib = (0, 1);
for (2..$n) {
push @fib, $fib[-1] + shift @fib;
}
return $fib[-1];
}
sub div {
return $_[0] / $_[1];
}
1;
use strict;
use warnings;
use Test::More 'no_plan';
use MyMath qw(add div fibo abs);
is(add(2, 3), 5);
#is(abs(-2), 2);
#is(abs(2), 2);
#is(fibo(0), 0);
#is(fibo(1), 1);
#is(fibo(2), 1);
#is(div(6, 3), 2);
#is(div(6, 0), 0);
use strict;
use warnings;
use ExtUtils::MakeMaker;
WriteMakefile
(
NAME => 'MyMath',
VERSION_FROM => 'lib/MyMath.pm',
LICENSE => 'perl',
PREREQ_PM => {
'Exporter' => '0',
},
TEST_REQUIRES => {
'Test::Simple' => '1.00',
},
);