NAME
Test::Lazy::Tester
SYNOPSIS
use Test::Lazy::Tester;
$tester = Test::Lazy::Tester->new;
# Will evaluate the code and check it:
$tester->try('qw/a/' => eq => 'a');
$tester->try('qw/a/' => ne => 'b');
$tester->try('qw/a/' => is => ['a']);
# Don't evaluate, but still compare:
$tester->check(1 => is => 1);
$tester->check(0 => isnt => 1);
$tester->check(a => like => qr/[a-zA-Z]/);
$tester->check(0 => unlike => qr/a-zA-Z]/);
$tester->check(1 => '>' => 0);
$tester->check(0 => '<' => 1);
# A failure example:
$tester->check([qw/a b/] => is => [qw/a b c/]);
# Failed test '['a','b'] is ['a','b','c']'
# Compared array length of $data
# got : array with 2 element(s)
# expect : array with 3 element(s)
# Custom test explanation:
$tester->try('2 + 2' => '==' => 5, "Math is hard: %?");
# Failed test 'Math is hard: 2 + 2 == 5'
# got: 4
# expected: 5
DESCRIPTION
See Test::Lazy for more information.
METHODS
Test::Lazy::Tester->new( cmp_scalar => ?, cmp_structure => ?, render => ? )
Create a new Test::Lazy::Tester object, optionally amending the scalar comparison, structure comparison, and render subroutines using the supplied hashes.
For now, more information on customization can be gotten by:
perldoc -m Test::Lazy::Tester
$tester->check( <got>, <compare>, <expect>, [ <notice> ] )
See Test::Lazy::check for details.
$tester->try( <got>, <compare>, <expect>, [ <notice> ] )
See Test::Lazy::try for details.
$tester->template()
Creates a Test::Lazy::Template
using $tester as the basis.
See Test::Lazy::Template for more details.
Returns a new Test::Lazy::Template object.
$tester->render_value( <value> )
Render a gotten or expected value to a form suitable for the test notice/explanation.
This method will consult the $tester->render hash to see what if should do based on 'ref <value>'. By default, ARRAY and HASH are handled by Data::Dumper using the following:
local $Data::Dumper::Indent = 0;
local $Data::Dumper::Varname = 0;
local $Data::Dumper::Terse = 1;
An undef value is a special case, handled by the $tester->render->{undef} subroutine. By default, the subroutine returns the string "undef"
$tester->render_notice( <left>, <compare>, <right>, <notice> )
Render the text explantaion message. You don't need to mess with this.