Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Test.pm consider "Null PMC access" an invalid death in dies_ok #1144

Closed
p6rt opened this issue Jul 16, 2009 · 9 comments
Closed

Make Test.pm consider "Null PMC access" an invalid death in dies_ok #1144

p6rt opened this issue Jul 16, 2009 · 9 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jul 16, 2009

Migrated from rt.perl.org#67622 (status was 'resolved')

Searchable as RT67622$

@p6rt
Copy link
Author

p6rt commented Jul 16, 2009

From @kyleha

Sometimes something dies, as it should, but with the wrong error. The
best way to test this is to specify the correct error, but we don't
always have the correct error. This patch makes dies_ok reject a
particular Rakudo-specific error that is always incorrect.

Kyle.

@p6rt
Copy link
Author

p6rt commented Jul 16, 2009

From @kyleha

0001--Test.pm-dies_ok-should-not-be-ok-when-death-is-fro.patch
From 8eb6fc78316e686bec5749b6e3baae1b86d56375 Mon Sep 17 00:00:00 2001
From: Kyle Hasselbacher <kyle@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 |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Test.pm b/Test.pm
index 0f90a16..3770d73 100644
--- a/Test.pm
+++ b/Test.pm
@@ -123,7 +123,7 @@ multi sub dies_ok(Callable $closure, $reason) is export(:DEFAULT) {
     try {
         $closure();
     }
-    proclaim((defined $!), $reason);
+    proclaim((defined $! && "$!" !~~ / ^ 'Null PMC access ' /), $reason);
 }
 multi sub dies_ok(Callable $closure) is export(:DEFAULT) {
     dies_ok($closure, '');
@@ -140,7 +140,8 @@ 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);
+    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

@p6rt
Copy link
Author

p6rt commented Jul 16, 2009

From @moritz

Kyle Hasselbacher (via RT) wrote​:

Sometimes something dies, as it should, but with the wrong error. The
best way to test this is to specify the correct error, but we don't
always have the correct error. This patch makes dies_ok reject a
particular Rakudo-specific error that is always incorrect.

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

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Jul 16, 2009

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jul 17, 2009

From @kyleha

On Thu, Jul 16, 2009 at 4​:30 PM, Moritz Lenz via
RT<perl6-bugs-followup@​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)

@p6rt
Copy link
Author

p6rt commented Jul 17, 2009

From @kyleha

0001--Test.pm-dies_ok-should-not-be-ok-when-death-is-fro.patch
From c7aa28fa2dc31d48f805a66b0cff38386a3d6273 Mon Sep 17 00:00:00 2001
From: Kyle Hasselbacher <kyle@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

@p6rt
Copy link
Author

p6rt commented Jul 17, 2009

From @moritz

On Thu Jul 16 21​:00​:50 2009, KyleHa wrote​:

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)

Thanks for the new patch, that behaviour looks much better. I'll test it
over the weekend (I'll be mostly offline) and fudge the places in the
test suite where it becomes necessary.

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Jul 20, 2009

From @moritz

On Thu Jul 16 21​:00​:50 2009, KyleHa wrote​:

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)

Thanks, applied.
Moritz

@p6rt
Copy link
Author

p6rt commented Jul 20, 2009

@moritz - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Jul 20, 2009
@p6rt p6rt added the patch label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant