Skip to content

Commit 9c0f7ec

Browse files
committed
LTM tests should use subparse
1 parent d626eb7 commit 9c0f7ec

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

S05-grammar/protoregex.t

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ grammar Alts {
1212
token alt:sym«=>» { <sym> }; # RT #113590
1313
}
1414

15-
ok (my $match = Alts.parse('foo')), 'can parse with proto regexes (1)';
15+
ok (my $match = Alts.subparse('foo')), 'can parse with proto regexes (1)';
1616

1717
is $match, 'foo', 'and matched the full string';
1818
is $match<alt>, 'foo', 'got the right name of the capture';
1919

2020
is $/, 'foo', 'also works with $/';
2121

22-
ok Alts.parse('bar'), 'can parse with second alternative';
23-
ok Alts.parse('argl'), 'can parse third second alternative';
22+
ok Alts.subparse('bar'), 'can parse with second alternative';
23+
ok Alts.subparse('argl'), 'can parse third second alternative';
2424

25-
ok !Alts.parse('baz'), 'does not match sym of third alternative';
26-
ok !Alts.parse('aldkfj'), 'does not match completely unrelated string';
27-
ok !Alts.parse(''), 'does not match empty string';
25+
ok !Alts.subparse('baz'), 'does not match sym of third alternative';
26+
ok !Alts.subparse('aldkfj'), 'does not match completely unrelated string';
27+
ok !Alts.subparse(''), 'does not match empty string';
2828

2929
# RT #113590
30-
ok Alts.parse('=>'), 'can parse symbol inside double-angles';
30+
ok Alts.subparse('=>'), 'can parse symbol inside double-angles';
3131

3232

3333
class SomeActions {
@@ -36,7 +36,7 @@ class SomeActions {
3636
}
3737
}
3838

39-
ok ($match = Alts.parse('argl', :actions(SomeActions.new))),
39+
ok ($match = Alts.subparse('argl', :actions(SomeActions.new))),
4040
'can parse with action methods';
4141
is $match<alt>.ast, 'bazbaz', 'action method got called, make() worked';
4242

@@ -104,21 +104,21 @@ grammar LTM {
104104
token block:sym<b> { aa }
105105
}
106106

107-
is ~LTM.parse('foobar', :rule('lit')), 'foobar', 'LTM picks longest literal';
108-
is ~LTM.parse('1.2', :rule('cclass1')), '1.2', 'LTM picks longest with char classes';
109-
is ~LTM.parse('1.2', :rule('cclass2')), '1.2', '...and it not just luck with ordering';
110-
is ~LTM.parse('11', :rule('cclass3')), '11', 'LTM works with things like \d';
111-
is ~LTM.parse('..', :rule('cclass4')), '..', '...and negated ones like \W';
112-
is ~LTM.parse('ab', :rule('quant1')), 'ab', 'LTM and ? quantifier';
113-
is ~LTM.parse('abbb', :rule('quant2')), 'abbb', 'LTM, ? and + quantifiers';
114-
is ~LTM.parse('aaaa', :rule('quant3')), 'aaaa', 'LTM and * quantifier';
115-
is ~LTM.parse('aaa', :rule('declok')), 'aaa', ':my declarations do not terminate LTM';
116-
is ~LTM.parse('aaa', :rule('cap1')), 'aaa', 'Positional captures do not terminate LTM';
117-
is ~LTM.parse('aaa', :rule('cap2')), 'aaa', 'Named captures do not terminate LTM';
118-
is ~LTM.parse('aaa', :rule('ass1')), 'aaa', '<?{...}> does not terminate LTM';
119-
is ~LTM.parse('aaa', :rule('ass2')), 'aaa', '<!{...}> does not terminate LTM';
107+
is ~LTM.subparse('foobar', :rule('lit')), 'foobar', 'LTM picks longest literal';
108+
is ~LTM.subparse('1.2', :rule('cclass1')), '1.2', 'LTM picks longest with char classes';
109+
is ~LTM.subparse('1.2', :rule('cclass2')), '1.2', '...and it not just luck with ordering';
110+
is ~LTM.subparse('11', :rule('cclass3')), '11', 'LTM works with things like \d';
111+
is ~LTM.subparse('..', :rule('cclass4')), '..', '...and negated ones like \W';
112+
is ~LTM.subparse('ab', :rule('quant1')), 'ab', 'LTM and ? quantifier';
113+
is ~LTM.subparse('abbb', :rule('quant2')), 'abbb', 'LTM, ? and + quantifiers';
114+
is ~LTM.subparse('aaaa', :rule('quant3')), 'aaaa', 'LTM and * quantifier';
115+
is ~LTM.subparse('aaa', :rule('declok')), 'aaa', ':my declarations do not terminate LTM';
116+
is ~LTM.subparse('aaa', :rule('cap1')), 'aaa', 'Positional captures do not terminate LTM';
117+
is ~LTM.subparse('aaa', :rule('cap2')), 'aaa', 'Named captures do not terminate LTM';
118+
is ~LTM.subparse('aaa', :rule('ass1')), 'aaa', '<?{...}> does not terminate LTM';
119+
is ~LTM.subparse('aaa', :rule('ass2')), 'aaa', '<!{...}> does not terminate LTM';
120120
#?niecza todo '#89'
121-
is ~LTM.parse('aaa', :rule('block')), 'aa', 'However, code blocks do terminate LTM';
121+
is ~LTM.subparse('aaa', :rule('block')), 'aa', 'However, code blocks do terminate LTM';
122122

123123
# RT120146
124124
#?niecza skip "Action method assertion:sym<...> not yet implemented"
@@ -130,16 +130,16 @@ is ~LTM.parse('aaa', :rule('block')), 'aa', 'However, code blocks do termi
130130
token ident {'-'?<nmstrt><nmreg>*}
131131
token num {[\+|\-]?\d+}
132132

133-
proto token term { <...> }
133+
proto token term {*}
134134
token term:sym<ident> {<ident>}
135135
token term:sym<num> {<num>}
136136
}
137137

138-
is ~G.parse("-42", :rule<num>), '-42', 'num parse';
139-
is ~G.parse("-my_id", :rule<ident>), '-my_id', 'id parse';
140-
is ~G.parse("my_id", :rule<term>), 'my_id', 'term parse';
138+
is ~G.subparse("-42", :rule<num>), '-42', 'num parse';
139+
is ~G.subparse("-my_id", :rule<ident>), '-my_id', 'id parse';
140+
is ~G.subparse("my_id", :rule<term>), 'my_id', 'term parse';
141141
#?rakudo todo 'RT120146'
142-
is ~G.parse("-my_id", :rule<term>), '-my_id', 'term parse, leading "-"';
142+
is ~G.subparse("-my_id", :rule<term>), '-my_id', 'term parse, leading "-"';
143143
}
144144

145145
# vim: ft=perl6

0 commit comments

Comments
 (0)