In my other post I stopped just short of proposing
sub lives_and_tests_ok (&&;$) { my ($case, $test, $name) = @_; local $@; my $result = eval { $case->() }; $@ ? fail($name) : $test->($result, $name); }
because it’s somewhat confusing to read the following:
lives_and_tests_ok ( sub { $o->answer }, sub { is shift, 42, shift }, "answer is 42" );
I briefly pondered
sub lives_and_tests_ok (&&;$) { my ($case, $test, $name) = @_; local $@; local ($b, $a) = ($name, eval { $case->() }); $@ ? fail($name) : $test->($result, $name); }
but I don’t think it’s any more readable than
lives_and_tests_ok ( sub { $o->answer }, sub { is $a, 42, $b }, "answer is 42" );
Makeshifts last the longest.
In reply to Re^3: Test::Exception extension with (evil?) overloading
by Aristotle
in thread Test::Exception extension with (evil?) overloading
by adrianh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |