Example 5-8. examples/intro/t04_calc.t
#!/usr/bin/perl
use strict;
use warnings;
ok(`./mycalc 1 + 1` == 2);
ok(`./mycalc 2 + 2` == 4);
ok(`./mycalc 2 + 2 + 2` == 6);
sub ok {
my ($ok) = @_;
print $ok ? "ok\n" : "not ok\n";
}Output:
But why reinvent the wheel ?
Besides, if there are lots of tests, we would need some way to easily recognise which test(s) fail. So we should put a counter on our tests.
| Prev | Home (Copyright Gabor Szabo) Perl Training Israel | Next |
| Print only ok/not ok | Up | Introducing Test::Simple |