Test::Proto::Fail - indicates the test has failed, and why
$turnip_result = @turnips ? 1 : Test::Proto::Fail->new('Out of turnips'); $broth_result = Test::Proto::Fail->new('No broth', $turnip_result) # i.e. $broth_result = $turnip_result ? 1 : Test::Proto::Fail->new('No broth')->because($turnip_result); print $broth_result;
Prints either 1 (if you have turnips) or an object which stringifies to:
Test Prototype failure: No broth Because: Out of turnips
NB: Do not confuse with Test::More::fail - this is more like carp-like functionality to the $why element of tests.
Test::More::fail
carp
$why
Test::Proto::Fail->new('Out of turnips')
Creats a new failure. The warning you give is the reason for the failure. Optionally, add the failure which caused this failure as a third argument (if this is boolean true, then it will return true instead).
$fail->because($turnip_result);
Set the triggering failure and return the failure. If the triggering failure is boolean true, then return that instead.
Currently all other public methods are via overloading:
All numeric operators treat Test::Proto::Fail objects as 0.
When stringified, however, Test::Proto::Fail objects return the explanation for the failure.
For author, version, bug reports, support, etc, please see Test::Proto.
To install Test::Proto, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Proto
CPAN shell
perl -MCPAN -e shell install Test::Proto
For more information on module installation, please visit the detailed CPAN module installation guide.