Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix some uses of eval
those were still assuming that eval catches exceptions
  • Loading branch information
moritz committed May 14, 2012
1 parent a42f0a6 commit 31af067
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
21 changes: 9 additions & 12 deletions S02-lexical-conventions/comments.t
Expand Up @@ -4,7 +4,7 @@ use v6;

use Test;

plan 46;
plan 44;

# L<S02/"Embedded Comments"/"Embedded comments"
# "#" plus any bracket>
Expand All @@ -20,7 +20,7 @@ plan 46;
Parens works also
) 1, 'multiline embedded comment with #`()';

ok eval("2 * 3\n #`<<<\n comment>>>"), "multiline comment with <<<";
eval_lives_ok "2 * 3\n #`<<<\n comment>>>", "multiline comment with <<<";

my $var = #`{ foo bar } 32;
is $var, 32, 'embedded comment with #`{}';
Expand Down Expand Up @@ -60,13 +60,12 @@ plan 46;

# L<S02/"Embedded Comments"/"no space" between "#" and bracket>
#?niecza skip 'Opening bracket is required for #` comment'
#?rakudo skip 'Whitespace character is not allowed as a delimiter'
{

ok !eval("3 * #` (invalid comment) 2"), "no space allowed between '#`' and '('";
ok !eval("3 * #`\t[invalid comment] 2"), "no tab allowed between '#`' and '['";
ok !eval("3 * #` \{invalid comment\} 2"), "no spaces allowed between '#`' and '\{'";
ok !eval("3 * #`\n<invalid comment> 2"), "no spaces allowed between '#`' and '<'";
eval_dies_ok "3 * #` (invalid comment) 2", "no space allowed between '#`' and '('";
eval_dies_ok "3 * #`\t[invalid comment] 2", "no tab allowed between '#`' and '['";
eval_dies_ok "3 * #` \{invalid comment\} 2", "no spaces allowed between '#`' and '\{'";
eval_dies_ok "3 * #`\n<invalid comment> 2", "no spaces allowed between '#`' and '<'";

}

Expand Down Expand Up @@ -124,7 +123,7 @@ plan 46;
# comment() before seeing that I meant #`{ comment within this string.

#?pugs todo 'bug'
ok eval(" #`<<\n comment\n # >>\n >> 3"),
eva_lives_ok " #`<<\n comment\n # >>\n >> 3",
'single line comment cannot correctly nested within multiline';
}

Expand Down Expand Up @@ -157,16 +156,14 @@ plan 46;
#?niecza skip 'Excess arguments to CORE eval'
#?rakudo skip 'Too many positional parameters passed'
{
my $a;
ok !eval '$a = #`\ (comment) 32', "comments can't contain unspace";
ok !$a.defined, '$a remains undefined';
eval_dies_ok '$a = #`\ (comment) 32', "comments can't contain unspace";
}

# L<S02/Single-line Comments/"# may not be used as"
# delimiter quoting>
{
my $a;
ok eval('$a = q{ 32 }'), 'sanity check';
lives_ok { eval('$a = q{ 32 }') }, 'sanity check';
is $a, ' 32 ', 'sanity check';

$a = Nil;
Expand Down
2 changes: 1 addition & 1 deletion S32-container/roundrobin.t
Expand Up @@ -21,7 +21,7 @@ is roundrobin(1).join, '1', 'roundrobin scalar identity';

is(roundrobin(1..3).Str, (1..3).Str, 'roundrobin list identity');

#?rakudo todo 'over-flattening
#?rakudo todo 'over-flattening'
is(roundrobin([1..3]).elems, 1, 'roundrobin does not flatten array items');


Expand Down

0 comments on commit 31af067

Please sign in to comment.