package Test::Lazy::Template; use strict; use warnings; use base qw/Class::Accessor::Fast/; __PACKAGE__->mk_accessors(qw/tester template/); use Test::Lazy::Tester; use Test::Builder(); use Scalar::Util qw/blessed/; use Carp; =head1 NAME Test::Lazy::Template =head1 SYNOPSIS Build 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 } ], ]); =head1 METHODS =head2 Test::Lazy::Template->new(