Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

54 lines (40 sloc) 1.251 kB
use v6;
use Test;
=begin pod
This file was derived from the perl5 CPAN module Perl6::Rules,
version 0.3 (12 Apr 2004), file t/codevars.t.
It has (hopefully) been, and should continue to be, updated to
be valid perl6.
=end pod
# L<S05/Bracket rationalization/It now delimits an embedded closure>
plan 12;
{
my $x = 3;
my $y = 2;
ok 'a' ~~ /. { $y = $x; 0 }/, 'can match and execute a closure';
is $y, 3, 'could access and update outer lexicals';
}
#?rakudo skip 'assignment to match variables (dubious) RT #124946'
#?niecza skip 'assigning to readonly value'
{
ok("abc" ~~ m/a(bc){$<caught> = $0}/, 'Inner match');
is(~$/<caught>, "bc", 'Inner caught');
}
my $caught = "oops!";
ok("abc" ~~ m/a(bc){$caught = $0}/, 'Outer match');
is($caught, "bc", 'Outer caught');
#?rakudo skip 'assignment to match variables (dubious) RT #124947'
#?niecza skip 'assigning to readonly value'
{
ok("abc" ~~ m/a(bc){$0 = uc $0}/, 'Numeric match');
is($/, "abc", 'Numeric matched');
is($0, "BC", 'Numeric caught');
}
{
ok("abc" ~~ m/a(bc){make uc $0}/ , 'Zero match');
#?niecza todo
#?rakudo todo 'make() inside closure'
is($($/), "BC", 'Zero matched');
is(~$0, "bc", 'One matched');
}
# vim: ft=perl6
Jump to Line
Something went wrong with that request. Please try again.