|
From Test::Simple to Test::Extreme - Bonus Material
|
48
|
|
|
Embedded Tests with Test::Extreme
another way of embedding tests in your modules with Test::Extreme:
package Rocket::PreFlight;
use Test::Extreme;
sub verify_min_max {
my ($actual, $min, $max) = @_;
return 1 if $actual <= $max and $actual >= $min;
return;
}
sub test_verify_min_max {
assert_true verify_min_max(5, 0, 20);
assert_true verify_min_max(666, 665, 667);
assert_true verify_min_max(666, 666, 666);
assert_false verify_min_max(666, 664, 665);
}
# at the end of the module
run_tests_as_script 'Rocket::PreFlight' if $0 =~ /Rocket\/PreFlight\.pm$/;
|
|