[Pdx-pm] Even more inline testing
Kris Bosland
krisb at ring.org
Thu Jun 16 13:59:51 PDT 2005
I am looking for a system that will let me run inline tests
without making a separate file. Something like
sumthing.pl:
=================================================
#!/your/perl/here -w
use strict;
eval {use Test::Inline::No::Really;}
if $ARGV[0] eq 'test';
=begin testing
is(summary(1,2,3,4,5), 15, "sum-tastic!");
exit;
=end testing
print qq{=> }, summary(@ARGV), qq{\n};
sub summary {
my $sum = 0;
foreach (@_) {
$sum += $_;
}
return $sum;
}
=================================================
sumthing.pl 1 2 3 4
=> 10
sumthing.pl test
ok 1 - sum-tastic!
Motivation: I am writing a CGI program that may
end up getting moved alot, and I don't want to
juggle a group of files with test files, etc.
I have found Pod::Tests, so I guess I could write
Test::Inline::No::Really like this:
=================================================
package Test::Inline::No::Really;
use Pod::Tests;
sub import {
my $p = Pod::Tests->new;
$p->parse_file($0);
eval $p->build_tests($p->tests);
}
=================================================
I thought there was an existing package like this
but I haven't found it after some googling today.
Can anyone give me some links or ideas?
Thanks.
-Kris
More information about the Pdx-pm-list
mailing list