This Won't EVER Happen to Me AGAIN
- And why do I need to display all that confusing noise when tests are OK?
#!/usr/bin/perl -w
use strict;
my @tests;
BEGIN {
@tests = (
[0 => 1],
[5 => 120],
[6 => 720],
);
require Test::Simple;
import Test::Simple tests => scalar(@tests);
}
foreach (@tests) {
my ($in, $out) = @$_;
my $res = MyMath::factorial($in);
ok($res == $out, "factorial($in)" . ($res == $out ? "" : " gave $res, expected $out"));
# Just stand back and admire the solution above
}
$ MyMath.t
1..3
ok 1 - factorial(0)
ok 2 - factorial(5)
ok 3 - factorial(6)