File Coverage

lib/Test/Lazy/Template.pm
Criterion Covered Total %
statement 61 65 93.8
branch 15 18 83.3
condition 2 3 66.6
subroutine 9 9 100.0
pod 2 2 100.0
total 89 97 91.7


line stmt bran cond sub pod time code
1             package Test::Lazy::Template;
2              
3 1     1   6 use strict;
  1         3  
  1         40  
4 1     1   7 use warnings;
  1         1  
  1         34  
5              
6 1     1   5 use base qw/Class::Accessor::Fast/;
  1         3  
  1         124  
7              
8             __PACKAGE__->mk_accessors(qw/tester template/);
9              
10 1     1   5 use Test::Lazy::Tester;
  1         2  
  1         10  
11 1     1   26 use Test::Builder();
  1         1  
  1         25  
12 1     1   5 use Scalar::Util qw/blessed/;
  1         2  
  1         70  
13 1     1   5 use Carp;
  1         2  
  1         827  
14              
15             =head1 NAME
16              
17             Test::Lazy::Template
18              
19             =head1 SYNOPSIS
20              
21             Build a template for running a similar set of tests repeatedly.
22              
23             The purpose of this module is to provide a convenient way of
24             testing a set of initial conditions in different ways.
25              
26             The best way to show this is in an example:
27              
28             # Template up the intial condition template.
29             my $template = new Test::Lazy::Template([
30             [ "qw/1/" ],
31             [ "qw/a/" ],
32             [ "qw/apple/" ],
33             [ "qw/2/" ],
34             [ "qw/0/" ],
35             [ "qw/-1/" ],
36             [ "map { \$_ => \$_ * 2 } qw/0 1 2 3 4/" ],
37             ]);
38              
39             # Run some different tests.
40             # NOTE: Don't have to use '%?' if the statement will run without modification.
41             $template->test("defined(%?)" => ok => undef);
42             $template->test("length(%?) >= 1" => ok => undef);
43             $template->test("length(%?)" => '>=' => 1);
44             $template->test("length(%?)" => '<' => 10);
45             $template->test([
46             [ '%?' => is => 1 ],
47             [ is => 'a' ],
48             [ is => 'apple' ],
49             [ is => 2 ],
50             [ is => 0 ],
51             [ is => is => -1 ],
52             [ is => { 0 => 0, 1 => 2, 2 => 4, 3 => 6, 4 => 8 } ],
53             ]);
54              
55             =head1 METHODS
56              
57             =head2 Test::Lazy::Template->new(