Skip to content

Commit 2454421

Browse files
committed
RT #111286 (named captures) and some other small fixes
1 parent b585e67 commit 2454421

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

S05-capture/named.t

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use v6;
22

33
use Test;
44

5-
plan 7;
5+
plan 10;
66

77
=begin pod
88
@@ -36,19 +36,29 @@ Testing named capture variables nested inside each other. This doesn't appear to
3636

3737
#L<S05/Subrule captures>
3838

39-
#?rakudo skip '$<alias> = <other>'
39+
#?rakudo skip 'assigning to match object'
4040
{
4141
my regex number {
42-
[ $<numeral> = <roman_numeral> { $<notation> = 'roman' }
43-
| $<numeral> = <arabic_numeral> { $<notation> = 'arabic' }
42+
[ $<numeral> = <&roman_numeral> { $<notation> = 'roman' }
43+
| $<numeral> = <&arabic_numeral> { $<notation> = 'arabic' }
4444
]
4545
};
46-
regex roman_numeral { I | II | III | IV };
47-
regex arabic_numeral { 1 | 2 | 3 | 4 };
46+
my regex roman_numeral { I | II | III | IV };
47+
my regex arabic_numeral { 1 | 2 | 3 | 4 };
4848
2 ~~ m/<number>/;
4949
is($/<number><numeral>, '2', 'binding subrule to new alias');
5050
is($/<number><notation>, 'roman', 'binding to alias as side-effect');
5151
}
5252

53+
# RT #111286
54+
{
55+
my grammar G {
56+
token TOP { <a>? $<b>='b' }
57+
token a { a }
58+
}
59+
ok G.parse('ab'), 'grammar sanity';
60+
is $/.keys.map(~*).sort.join(', '), 'a, b', 'right keys in top level match';
61+
is $<b>.elems, 0, '$<b> has no captures';
62+
}
5363

5464
# vim: ft=perl6

0 commit comments

Comments
 (0)