in reply to Re^2: Test::Exception extension with (evil?) overloading
in thread Test::Exception extension with (evil?) overloading
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Test::Exception extension with (evil?) overloading
by adrianh (Chancellor) on Jan 18, 2003 at 21:50 UTC | |
by Aristotle (Chancellor) on Jan 18, 2003 at 22:11 UTC | |
by adrianh (Chancellor) on Jan 18, 2003 at 23:15 UTC |