On Thu, Jul 16, 2009 at 4:30 PM, Moritz Lenz via RT<perl6-bugs-follo...@perl.org> wrote:
> I like the idea very much, but the current implementation is a bit > confusing. The test code dies, but dies_ok still fails. Maybe adding a > diag($explanation) might improve that. (Maybe I get around to implement > that, but right now I'm not very concentrated). Here's a new patch. Now a failure looks like this (example from S05-metasyntax/angle-brackets.t) # wrong way to die: 'Null PMC access in invoke()' not ok 3 - <...> without whitespace calls a function (not quote words)
From c7aa28fa2dc31d48f805a66b0cff38386a3d6273 Mon Sep 17 00:00:00 2001 From: Kyle Hasselbacher <k...@livetext.com> Date: Wed, 15 Jul 2009 12:40:05 -0500 Subject: [PATCH] [Test.pm] dies_ok should not be ok when death is from "Null PMC access" [Test.pm] eval_dies_ok should also not accept "Null PMC access" [Test.pm] use diag() to report Null PMC access failures of dies_ok --- Test.pm | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Test.pm b/Test.pm index 0f90a16..72517d0 100644 --- a/Test.pm +++ b/Test.pm @@ -123,7 +123,10 @@ multi sub dies_ok(Callable $closure, $reason) is export(:DEFAULT) { try { $closure(); } - proclaim((defined $!), $reason); + if "$!" ~~ / ^ 'Null PMC access ' / { + diag "wrong way to die: '$!'"; + } + proclaim((defined $! && "$!" !~~ / ^ 'Null PMC access ' /), $reason); } multi sub dies_ok(Callable $closure) is export(:DEFAULT) { dies_ok($closure, ''); @@ -140,7 +143,11 @@ multi sub lives_ok(Callable $closure) is export(:DEFAULT) { } multi sub eval_dies_ok(Str $code, $reason) is export(:DEFAULT) { - proclaim((defined eval_exception($code)), $reason); + my $ee = eval_exception($code); + if "$ee" ~~ / ^ 'Null PMC access ' / { + diag "wrong way to die: '$ee'"; + } + proclaim((defined $ee && "$ee" !~~ / ^ 'Null PMC access' /), $reason); } multi sub eval_dies_ok(Str $code) is export(:DEFAULT) { eval_dies_ok($code, ''); -- 1.6.0.4