Contextual-Return
view release on metacpan or search on metacpan
t/fail_with.t view on Meta::CPAN
eval_nok { Other::fail_auto_message() } 'good' => 'Exception thrown in void context';
eval_nok { () = Other::fail_auto_message() } 'good' => 'Exception thrown in list context';
eval_nok { my $x = Other::fail_auto_message(); $x+1 } 'good' => 'Exception thrown in num context';
eval_nok { my $x = Other::fail_auto_message(); $x.'a' } 'good' => 'Exception thrown in str context';
sub set_up_2 {
package Other;
my $LINE = (caller)[2];
local $SIG{__WARN__} = sub {
my $message = shift;
::is $message,
'FAIL handler for package Other redefined at '.__FILE__
." line $LINE\n"
=> 'Redefinition warning as expected'
};
Contextual::Return::FAIL_WITH -fail => $FAIL_SPEC_ref, qw(if you fail good -fail bad);
}
t/fail_with.t view on Meta::CPAN
}
else {
ok 0 => 'Unexpected failed in bool context';
}
my @results = Other::fail_auto_message();
ok @results == 0 => 'Returned empty list in list context';
sub set_up_3 {
package Other;
my $LINE = (caller)[2];
local $SIG{__WARN__} = sub {
my $message = shift;
::is $message,
'FAIL handler for package Other redefined at '.__FILE__
." line $LINE\n"
=> 'Redefinition warning as expected'
};
eval {
Contextual::Return::FAIL_WITH -fail => $FAIL_SPEC_ref, -fail => 'unknown';
};
( run in 1.070 second using v1.01-cache-2.11-cpan-56fb94df46f )