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
eval_(dies|lives)_ok methods for rakudo's Test.pm, and more tests #116
Comments
From @moritzAttached patch, mostly courtesy Vasily "bacek" Chekalkin, adds the -- |
From @moritzOops, forgot to attach patch. Now it's really there. -- |
From @moritzeval_stuff.patchIndex: languages/perl6/t/spectest_regression.data
===================================================================
--- languages/perl6/t/spectest_regression.data (revision 28065)
+++ languages/perl6/t/spectest_regression.data (working copy)
@@ -6,6 +6,8 @@
S02-literals/autoref.t
S02-literals/hex_chars.t
S02-literals/radix.t
+S02-polymorphic_types/subset-code.t # pure
+S02-polymorphic_types/subset-range.t
S03-operators/autoincrement.t # pure
S03-operators/comparison.t
S03-operators/cross-metaop.t
@@ -39,6 +41,7 @@
S29-list/map_empty_list.t
S29-list/map_flattening.t
S29-list/map_function_return_values.t
+S29-list/map.t
S29-list/mutating_listops.t # pure
S29-list/sort.t
S29-num/abs.t
Index: languages/perl6/Test.pm
===================================================================
--- languages/perl6/Test.pm (revision 28065)
+++ languages/perl6/Test.pm (working copy)
@@ -122,7 +122,23 @@
lives_ok($closure, '');
}
+multi sub eval_dies_ok($code, $reason) {
+ eval ( $code );
+ proclaim((defined $!), $reason);
+}
+multi sub eval_dies_ok($code) {
+ eval_dies_ok($code, '');
+}
+multi sub eval_lives_ok($code, $reason) {
+ try { eval ($code) }
+ proclaim((not defined $!), $reason);
+}
+multi sub eval_lives_ok($code) {
+ eval_lives_ok($code, '');
+}
+
+
## 'private' subs
sub proclaim($cond, $desc) {
|
From @particleOn Wed, Jun 4, 2008 at 2:46 PM, Moritz Lenz <moritz@casella.verplant.org> wrote:
thanks, applied as of r28074. |
The RT System itself - Status changed from 'new' to 'open' |
From @ronaldxsMoritz Lenz wrote:
Your implementations of eval_lives_ok and eval_dies_ok seem $ svn diff Test.pm
|
From @moritzRonald Schmidt wrote:
Good catch. Actually I already encountered I problem with these two Are there any exceptions that are not caught by eval? So eval() needs more work, but in the mean time your patch works just Cheers,
-- |
From @particleOn Thu, Jun 5, 2008 at 3:05 PM, Moritz Lenz <moritz@casella.verplant.org> wrote:
agreed, good catch. applied with some formatting tweaks (eg. putting |
From @particleOn Fri, Jun 6, 2008 at 7:34 PM, Vasily Chekalkin <bacek@bacek.com> wrote:
would you reformat this in universal diff format please? my patch |
From @bacekOn Fri Jun 06 20:11:36 2008, particle wrote: (Sorry for spam if any. Looks like my message was rejected by mailman.) eval() shouldn't throws any exceptions. Correct patch for 'eval()' and Test.pm attached. -- |
From @bacekeval2.diff===================================================
--- Test.pm (orig)
+++ Test.pm (modified)
@@ -123,14 +123,16 @@ multi sub lives_ok($closure) {
}
multi sub eval_dies_ok($code, $reason) {
- proclaim((defined eval_exception($code)), $reason);
+ eval($code);
+ proclaim(defined($!), $reason);
}
multi sub eval_dies_ok($code) {
eval_dies_ok($code, '');
}
multi sub eval_lives_ok($code, $reason) {
- proclaim((not defined eval_exception($code)), $reason);
+ eval($code);
+ proclaim((not defined $!), $reason);
}
multi sub eval_lives_ok($code) {
eval_lives_ok($code, '');
@@ -139,12 +141,6 @@ multi sub eval_lives_ok($code) {
## 'private' subs
-sub eval_exception($code) {
- my $eval_exception;
- try { eval ($code); $eval_exception = $! }
- $eval_exception // $!;
-}
-
sub proclaim($cond, $desc) {
$testing_started = 1;
$num_of_tests_run = $num_of_tests_run + 1;
===================================================
--- src/builtins/control.pir (orig)
+++ src/builtins/control.pir (modified)
@@ -113,13 +113,12 @@ on error.
unless have_lang goto no_lang
'die'('Lanuage parameter to eval unimplemented.')
no_lang:
+ push_eh catch
.local pmc compiler, invokable
.local pmc res, exception
compiler = compreg 'Perl6'
invokable = compiler.'compile'(code)
-
- push_eh catch
res = invokable()
pop_eh
exception = new 'Failure'
|
From @bacekjerry gay wrote:
This is wrong patch. eval() shouldn't throws any exceptions. Correct patch for 'eval()' and Test.pm attached. -- |
From @bacekeval.diffdiff --git a/languages/perl6/Test.pm b/languages/perl6/Test.pm
index 5cb04ae..ccc34a9 100644
--- a/languages/perl6/Test.pm
+++ b/languages/perl6/Test.pm
@@ -123,14 +123,16 @@ multi sub lives_ok($closure) {
}
multi sub eval_dies_ok($code, $reason) {
- proclaim((defined eval_exception($code)), $reason);
+ eval(code);
+ proclaim(defined($!), $reason);
}
multi sub eval_dies_ok($code) {
eval_dies_ok($code, '');
}
multi sub eval_lives_ok($code, $reason) {
- proclaim((not defined eval_exception($code)), $reason);
+ eval($code);
+ proclaim((not defined $!), $reason);
}
multi sub eval_lives_ok($code) {
eval_lives_ok($code, '');
@@ -139,12 +141,6 @@ multi sub eval_lives_ok($code) {
## 'private' subs
-sub eval_exception($code) {
- my $eval_exception;
- try { eval ($code); $eval_exception = $! }
- $eval_exception // $!;
-}
-
sub proclaim($cond, $desc) {
$testing_started = 1;
$num_of_tests_run = $num_of_tests_run + 1;
diff --git a/languages/perl6/src/builtins/control.pir b/languages/perl6/src/builtins/control.pir
index 479b1b6..558a4c4 100644
--- a/languages/perl6/src/builtins/control.pir
+++ b/languages/perl6/src/builtins/control.pir
@@ -113,13 +113,12 @@ on error.
unless have_lang goto no_lang
'die'('Lanuage parameter to eval unimplemented.')
no_lang:
+ push_eh catch
.local pmc compiler, invokable
.local pmc res, exception
compiler = compreg 'Perl6'
invokable = compiler.'compile'(code)
-
- push_eh catch
res = invokable()
pop_eh
exception = new 'Failure'
|
From @bacekjerry gay wrote:
Strange... It is 'universal diff' format. Can be applied with Anyway, attached patch can be applied within 'patch -p0' in -- |
From @bacekeval2.diff===================================================
--- Test.pm (orig)
+++ Test.pm (modified)
@@ -123,14 +123,16 @@ multi sub lives_ok($closure) {
}
multi sub eval_dies_ok($code, $reason) {
- proclaim((defined eval_exception($code)), $reason);
+ eval(code);
+ proclaim(defined($!), $reason);
}
multi sub eval_dies_ok($code) {
eval_dies_ok($code, '');
}
multi sub eval_lives_ok($code, $reason) {
- proclaim((not defined eval_exception($code)), $reason);
+ eval($code);
+ proclaim((not defined $!), $reason);
}
multi sub eval_lives_ok($code) {
eval_lives_ok($code, '');
@@ -139,12 +141,6 @@ multi sub eval_lives_ok($code) {
## 'private' subs
-sub eval_exception($code) {
- my $eval_exception;
- try { eval ($code); $eval_exception = $! }
- $eval_exception // $!;
-}
-
sub proclaim($cond, $desc) {
$testing_started = 1;
$num_of_tests_run = $num_of_tests_run + 1;
===================================================
--- src/builtins/control.pir (orig)
+++ src/builtins/control.pir (modified)
@@ -113,13 +113,12 @@ on error.
unless have_lang goto no_lang
'die'('Lanuage parameter to eval unimplemented.')
no_lang:
+ push_eh catch
.local pmc compiler, invokable
.local pmc res, exception
compiler = compreg 'Perl6'
invokable = compiler.'compile'(code)
-
- push_eh catch
res = invokable()
pop_eh
exception = new 'Failure'
|
From @ronaldxsVasily Chekalkin wrote:
As Mr Lenz wrote with respect to eval exceptions and this patch:
For example: eval 'my $x = 2; $x = $x / 0; say eval 'my $x; my $y; ($x = $y) = 3; say In the second case eval throws an exception and it would make sense for Ron |
From @bacekOn Sat Jun 07 07:13:07 2008, ronaldxs wrote: Probably I don't understand correctly your question. This is output from $ ../../parrot perl6.pbc
Is it what you want? -- |
From allbery@ece.cmu.eduOn 2008 Jun 6, at 23:53, Vasily Chekalkin wrote:
Your mail program is mangling line endings (note last line of above -- |
From @moritzI'm resolving this ticket, because now (aka r28926) eval_lives_ok and If eval() still throws an exception in some cases that should be a Cheers, |
@moritz - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#55304 (status was 'resolved')
Searchable as RT55304$
The text was updated successfully, but these errors were encountered: