|
NAMETest::Lazy::TemplateSYNOPSISBuild a template for running a similar set of tests repeatedly.The purpose of this module is to provide a convenient way of testing a set of initial conditions in different ways. The best way to show this is in an example: # Template up the intial condition template. my $template = new Test::Lazy::Template([ [ "qw/1/" ], [ "qw/a/" ], [ "qw/apple/" ], [ "qw/2/" ], [ "qw/0/" ], [ "qw/-1/" ], [ "map { \$_ => \$_ * 2 } qw/0 1 2 3 4/" ], ]); # Run some different tests. # NOTE: Don't have to use '%?' if the statement will run without modification. $template->test("defined(%?)" => ok => undef); $template->test("length(%?) >= 1" => ok => undef); $template->test("length(%?)" => '>=' => 1); $template->test("length(%?)" => '<' => 10); $template->test([ [ '%?' => is => 1 ], [ is => 'a' ], [ is => 'apple' ], [ is => 2 ], [ is => 0 ], [ is => is => -1 ], [ is => { 0 => 0, 1 => 2, 2 => 4, 3 => 6, 4 => 8 } ], ]); METHODSTest::Lazy::Template->new( <template> )Test::Lazy::Template->new( <test>, <test>, ..., <test> )Create a new "Test::Lazy::Template" object using the giving test specification.If <template> is a SCALAR reference, then new will split <template> on each newline, ignoring empty lines and lines beginning with a pound (#). # You could do something like this: my $template = template(\<<_END_); qw/1/ qw/a/ qw/apple/ qw/2/ qw/0/ qw/-1/ # Let's test this one too. map { \$_ => \$_ * 2 } qw/0 1 2 3 4/ _END_ Returns the new "Test::Lazy::Template" object $template->test( <template> )For each test in $template, modify and run each the test according to the corresponding entry in <template>.$template->test( <test> )Modify and then run each test in $template by using <test> to complete each test's specification.
Visit the GSP FreeBSD Man Page Interface. |