NAME

Test::Proto::Fail - indicates the test has failed, and why

SYNOPSIS

$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.

METHODS

new

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).

because

$fail->because($turnip_result);

Set the triggering failure and return the failure. If the triggering failure is boolean true, then return that instead.

Other methods

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.

OTHER INFORMATION

For author, version, bug reports, support, etc, please see Test::Proto.