|
From Test::Simple to Test::Extreme - Embedding Tests in Your Code
|
26
|
|
|
Testing Your Pod Examples
Test::Inline lets you syntax check the code examples in your Pod:
=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.
=also begin example
verify_min_max($value, $min, $max) or die "Value is out of range!\n";
=also end example
=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;
}
|
|