|
From Test::Simple to Test::Extreme - Embedding Tests in Your Code
|
25
|
|
|
Embedding Tests in Pod
Test::Inline (formerly Pod::Tests) lets you embed simple tests in your documentation:
=head1 DIAGNOSTIC SUBROUTINES
=over 4
=item verify_min_max
This subroutine returns true if the given value is between a
minimum and a maximum value, and false otherwise.
verify_min_max($value, $min, $max) or die "Value is out of range!\n";
=begin testing
use strict;
use Test::Inline;
use Rocket::PreFlight;
ok(Rocket::PreFlight::verify_min_max(5, 0, 20), "verify_min_max(5, 0, 20)");
ok(Rocket::PreFlight::verify_min_max(666, 665, 667), "verify_min_max(666, 665, 667)");
ok(Rocket::PreFlight::verify_min_max(666, 666, 666), "verify_min_max(666, 666, 666)");
ok(!Rocket::PreFlight::verify_min_max(666, 664, 665), "!verify_min_max(666, 664, 665)");
=end testing
=cut
sub verify_min_max {
my ($actual, $min, $max) = @_;
return 1 if $actual <= $max and $actual >= $min;
return;
}
|
|