Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add test for RT #115372
  • Loading branch information
usev6 committed Oct 22, 2014
1 parent 1345d8b commit eae2dc7
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions S04-blocks-and-statements/pointy.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 17;
plan 18;

=begin description
Expand Down Expand Up @@ -30,7 +30,7 @@ is $got, 'x 123', 'called pointy immediately: -> $x { ... }(...)';

# L<S04/Statement-ending blocks/End-of-statement cannot occur within a bracketed expression>
my @a;
lives_ok { @a = ("one", -> $x { $x**2 }, "three")} ,
lives_ok { @a = ("one", -> $x { $x**2 }, "three")} ,
'pointy sub without preceding comma';
is @a[0], 'one', 'pointy sub in list previous argument';
isa_ok @a[1], Code, 'pointy sub in list';
Expand All @@ -39,7 +39,7 @@ is @a[2], 'three', 'pointy sub in list following argument';

# L<S06/""Pointy blocks""/behaves like a block with respect to control exceptions>
my $n = 1;
my $s = -> {
my $s = -> {
last if $n == 10;
$n++;
redo if $n < 10;
Expand All @@ -52,16 +52,16 @@ is $n, 10, "pointy control exceptions ran";
# L<S06/""Pointy blocks""/will return from the innermost enclosing sub or method>
my $str = '';

sub outer {
my $s = -> {
sub outer {
my $s = -> {
#?rakudo todo '&?ROUTINE'
#?niecza todo 'Unable to resolve method name in class Sub'
is(&?ROUTINE.name, '&Main::outer', 'pointy still sees outer\'s &?ROUTINE');
is(&?ROUTINE.name, '&Main::outer', 'pointy still sees outer\'s &?ROUTINE');

$str ~= 'inner';
return 'inner ret';
$str ~= 'inner';
return 'inner ret';
};
$s.();
$s.();
$str ~= 'outer';
return 'outer ret';
}
Expand All @@ -81,11 +81,10 @@ is $str, 'inner', 'return in pointy returns from enclosing sub';
eval_dies_ok(q{{ -> { $^a, $^b } }}, '-> { $^a, $^b } is illegal');

# RT #61034

lives_ok {my $x = -> {}; my $y = $x(); },
lives_ok {my $x = -> {}; my $y = $x(); },
'can define and execute empty pointy block';

# The default type of pointy blocks is Mu, not Any. See
# The default type of pointy blocks is Mu, not Any. See
# http://www.nntp.perl.org/group/perl.perl6.language/2009/03/msg31181.html
# L<S02/Undefined types/default block parameter type>
# this means that junctions don't autothread over pointy blocks
Expand All @@ -102,9 +101,15 @@ lives_ok {my $x = -> {}; my $y = $x(); },
ok $ok, 'Blocks receive junctions without autothreading';
is $iterations, 1, 'no autothreading happened';
my $b = -> $x { ... };
ok $b.signature.perl !~~ /Any/,
ok $b.signature.perl !~~ /Any/,
'The .signature of a block does not contain Any';
}

# vim: ft=perl6
# RT #115372
#?rakudo.moar todo 'RT #115372'
{
throws_like q[say -> {YOU_ARE_HERE}], X::Method::NotFound,
'no Segfault when putting YOU_ARE_HERE marker in a pointy block';
}

# vim: ft=perl6

0 comments on commit eae2dc7

Please sign in to comment.