Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Toss tests for semantics we've decided against.
We won't try to statically work out whether a "when"/"default" is a
valid thing, since it pretty much always can be, and folks have come
to make good use of those semantics.
  • Loading branch information
jnthn committed Jul 9, 2015
1 parent 6d6c4fb commit 5aa33ab
Showing 1 changed file with 1 addition and 34 deletions.
35 changes: 1 addition & 34 deletions S04-statements/when.t
@@ -1,39 +1,6 @@
use Test;

plan 24;

#?rakudo skip 'exception type X::Syntax::OutsideOfTopicalizer NYI RT #125132'
{
throws-like 'when 1 { }', X::Syntax::OutsideOfTopicalizer, keyword => 'when',
'when block in mainline complains about missing topicalizer';
throws-like 'default { }', X::Syntax::OutsideOfTopicalizer, keyword => 'default',
'default block in mainline complains about missing topicalizer';

throws-like '-> { when 1 { } }', X::Syntax::OutsideOfTopicalizer, keyword => 'when',
'when block in pointy not declaring $_ complains about missing topicalizer';
throws-like '-> { default { } }', X::Syntax::OutsideOfTopicalizer, keyword => 'default',
'default block in pointy not declaring $_ complains about missing topicalizer';

throws-like 'given 42 -> $a { when 1 { } }', X::Syntax::OutsideOfTopicalizer, keyword => 'when',
'when block in pointy on given not declaring $_ complains about missing topicalizer';
throws-like 'given 42 -> $a { default { } }', X::Syntax::OutsideOfTopicalizer, keyword => 'default',
'default block in pointy on given not declaring $_ complains about missing topicalizer';

throws-like 'for 1, 2, 3 -> $a { when 1 { } }', X::Syntax::OutsideOfTopicalizer, keyword => 'when',
'when block in pointy on for loop not declaring $_ complains about missing topicalizer';
throws-like 'for 1, 2, 3 -> $a { default { } }', X::Syntax::OutsideOfTopicalizer, keyword => 'default',
'default block in pointy on for loop not declaring $_ complains about missing topicalizer';

throws-like 'sub foo() { when 1 { } }', X::Syntax::OutsideOfTopicalizer, keyword => 'when',
'when block in sub not declaring $_ complains about missing topicalizer';
throws-like 'sub foo() { default { } }', X::Syntax::OutsideOfTopicalizer, keyword => 'default',
'default block in sub not declaring $_ complains about missing topicalizer';

throws-like 'my class C { method foo() { when 1 { } } }', X::Syntax::OutsideOfTopicalizer, keyword => 'when',
'when block in method not declaring $_ complains about missing topicalizer';
throws-like 'my class C { method foo() { default { } } }', X::Syntax::OutsideOfTopicalizer, keyword => 'default',
'default block in method not declaring $_ complains about missing topicalizer';
}
plan 12;

my $c = { when 1 { 'one' }; when 2 { 'two!' }; default { 'many' } };
is $c(1), 'one', 'when works in a circumfix:<{ }> (1)';
Expand Down

0 comments on commit 5aa33ab

Please sign in to comment.