Created
April 14, 2012 13:36
-
-
Save felher/2384508 to your computer and use it in GitHub Desktop.
Exceptoin.Bool patches
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 68286f0c9998650eb33dbc5047ccfd294a0f0c9f Mon Sep 17 00:00:00 2001 | |
From: Felix Herrmann <felix@herrmann-koenigsberg.de> | |
Date: Fri, 13 Apr 2012 20:38:52 +0200 | |
Subject: [PATCH] Make Exception.Bool return True | |
--- | |
src/core/Exception.pm | 2 -- | |
1 files changed, 0 insertions(+), 2 deletions(-) | |
diff --git a/src/core/Exception.pm b/src/core/Exception.pm | |
index 6386a8a..197e6dc 100644 | |
--- a/src/core/Exception.pm | |
+++ b/src/core/Exception.pm | |
@@ -27,8 +27,6 @@ my class Exception { | |
method rethrow() is hidden_from_backtrace { | |
pir::rethrow__0P($!ex) | |
} | |
- | |
- method Bool() { False } | |
} | |
my class X::AdHoc is Exception { | |
-- | |
1.7.8.5 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 0eba93afbb927748b16bf56eff4fd106906b6121 Mon Sep 17 00:00:00 2001 | |
From: Felix Herrmann <felix@herrmann-koenigsberg.de> | |
Date: Sat, 14 Apr 2012 15:05:45 +0200 | |
Subject: [PATCH] rewrite tests that rely on Exception to return False on | |
.Bool | |
--- | |
S02-literals/sub-calls.t | 2 +- | |
S06-signature/errors.t | 7 ++++--- | |
S14-roles/basic.t | 9 ++++++--- | |
S32-array/shift.t | 4 ++-- | |
4 files changed, 13 insertions(+), 9 deletions(-) | |
diff --git a/S02-literals/sub-calls.t b/S02-literals/sub-calls.t | |
index 1a7c94a..91dc971 100644 | |
--- a/S02-literals/sub-calls.t | |
+++ b/S02-literals/sub-calls.t | |
@@ -49,7 +49,7 @@ plan 20; | |
sub succ($x) { $x + 1 } | |
is(eval(q/succ (1+2) * 30;/), 91, "parens after space aren't call-parens"); | |
- nok(try {eval(q/succ .(1+2) * 30;/) }, 'parsed as method call on $_'); | |
+ dies_ok { eval q/succ .(1+2) * 30;/ } , 'parsed as method call on $_'; | |
} | |
{ | |
sub first() { "first" } | |
diff --git a/S06-signature/errors.t b/S06-signature/errors.t | |
index c53f69d..79ae49f 100644 | |
--- a/S06-signature/errors.t | |
+++ b/S06-signature/errors.t | |
@@ -28,10 +28,11 @@ eval_lives_ok 'sub quuuux ($!) { ... }', 'but $! is OK'; | |
# RT #71478 | |
{ | |
- my $success = try { eval 'sub foo(%h) { %h }; foo(1, 2); 1' }; | |
- my $error = "$!"; | |
- nok $success, | |
+ dies_ok { eval 'sub foo(%h) { %h }; foo(1, 2); 1' }, | |
"Passing two arguments to a function expecting one hash is an error"; | |
+ | |
+ try { eval 'sub foo(%h) { %h }; foo(1, 2); 1' }; | |
+ my $error = "$!"; | |
#?pugs todo | |
ok $error ~~ / '%h' /, '... error message mentions parameter'; | |
#?pugs todo | |
diff --git a/S14-roles/basic.t b/S14-roles/basic.t | |
index bcb1dc4..e067938 100644 | |
--- a/S14-roles/basic.t | |
+++ b/S14-roles/basic.t | |
@@ -91,9 +91,11 @@ dies_ok { HasC.new.x = 42 }, 'typed attribute rejects things it should'; | |
eval_dies_ok '0 but RT66178', '"but" with non-existent role dies'; | |
{ | |
- my $x = try eval 'class Animal does NonExistentRole { }; 1'; | |
+ dies_ok { eval 'class Animal does NonExistentRole { }; 1' }, | |
+ 'a class dies when it does a non-existent role'; | |
+ | |
+ try { eval 'class Animal does NonExistentRole { }; 1' }; | |
my $err = "$!"; | |
- ok !$x, 'a class dies when it does a non-existent role'; | |
#?rakudo todo 'nom regression' | |
ok $err ~~ /NonExistentRole/, | |
'... and the error message mentions the role'; | |
@@ -102,8 +104,9 @@ eval_dies_ok '0 but RT66178', '"but" with non-existent role dies'; | |
# RT #67278 | |
{ | |
class AClass { }; | |
+ dies_ok { eval 'class BClass does AClass { }; 1' }, | |
+ 'class SomeClass does AnotherClass dies'; | |
my $x = try eval 'class BClass does AClass { }; 1'; | |
- nok $x, 'class SomeClass does AnotherClass dies'; | |
ok "$!" ~~ /AClass/, 'Error message mentions the offending non-role'; | |
} | |
diff --git a/S32-array/shift.t b/S32-array/shift.t | |
index 290aa79..ee7f977 100644 | |
--- a/S32-array/shift.t | |
+++ b/S32-array/shift.t | |
@@ -82,8 +82,8 @@ plan 31; | |
my @shift = 1 .. 5; | |
eval_dies_ok('shift() ', 'shift() requires arguments'); | |
eval_dies_ok('42.shift', '.shift should not work on scalars'); | |
- nok(try { eval('shift(@shift, 10)') }, 'shift() should not allow extra arguments'); | |
- nok(try { eval(' @shift.shift(10)') }, 'shift() should not allow extra arguments'); | |
+ dies_ok { eval('shift(@shift, 10)') }, 'shift() should not allow extra arguments'; | |
+ dies_ok { eval(' @shift.shift(10)') }, 'shift() should not allow extra arguments'; | |
} | |
# Push with Inf arrays (waiting on answers to perl6-compiler email) | |
-- | |
1.7.8.5 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment