From 9c0f7ec379c509d96109a077d94ee382aea5c80b Mon Sep 17 00:00:00 2001 From: Larry Wall Date: Sun, 2 Mar 2014 14:22:57 -0800 Subject: [PATCH] LTM tests should use subparse --- S05-grammar/protoregex.t | 54 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/S05-grammar/protoregex.t b/S05-grammar/protoregex.t index 37af712bdf..e9925260de 100644 --- a/S05-grammar/protoregex.t +++ b/S05-grammar/protoregex.t @@ -12,22 +12,22 @@ grammar Alts { token alt:sym«=>» { }; # RT #113590 } -ok (my $match = Alts.parse('foo')), 'can parse with proto regexes (1)'; +ok (my $match = Alts.subparse('foo')), 'can parse with proto regexes (1)'; is $match, 'foo', 'and matched the full string'; is $match, 'foo', 'got the right name of the capture'; is $/, 'foo', 'also works with $/'; -ok Alts.parse('bar'), 'can parse with second alternative'; -ok Alts.parse('argl'), 'can parse third second alternative'; +ok Alts.subparse('bar'), 'can parse with second alternative'; +ok Alts.subparse('argl'), 'can parse third second alternative'; -ok !Alts.parse('baz'), 'does not match sym of third alternative'; -ok !Alts.parse('aldkfj'), 'does not match completely unrelated string'; -ok !Alts.parse(''), 'does not match empty string'; +ok !Alts.subparse('baz'), 'does not match sym of third alternative'; +ok !Alts.subparse('aldkfj'), 'does not match completely unrelated string'; +ok !Alts.subparse(''), 'does not match empty string'; # RT #113590 -ok Alts.parse('=>'), 'can parse symbol inside double-angles'; +ok Alts.subparse('=>'), 'can parse symbol inside double-angles'; class SomeActions { @@ -36,7 +36,7 @@ class SomeActions { } } -ok ($match = Alts.parse('argl', :actions(SomeActions.new))), +ok ($match = Alts.subparse('argl', :actions(SomeActions.new))), 'can parse with action methods'; is $match.ast, 'bazbaz', 'action method got called, make() worked'; @@ -104,21 +104,21 @@ grammar LTM { token block:sym { aa } } -is ~LTM.parse('foobar', :rule('lit')), 'foobar', 'LTM picks longest literal'; -is ~LTM.parse('1.2', :rule('cclass1')), '1.2', 'LTM picks longest with char classes'; -is ~LTM.parse('1.2', :rule('cclass2')), '1.2', '...and it not just luck with ordering'; -is ~LTM.parse('11', :rule('cclass3')), '11', 'LTM works with things like \d'; -is ~LTM.parse('..', :rule('cclass4')), '..', '...and negated ones like \W'; -is ~LTM.parse('ab', :rule('quant1')), 'ab', 'LTM and ? quantifier'; -is ~LTM.parse('abbb', :rule('quant2')), 'abbb', 'LTM, ? and + quantifiers'; -is ~LTM.parse('aaaa', :rule('quant3')), 'aaaa', 'LTM and * quantifier'; -is ~LTM.parse('aaa', :rule('declok')), 'aaa', ':my declarations do not terminate LTM'; -is ~LTM.parse('aaa', :rule('cap1')), 'aaa', 'Positional captures do not terminate LTM'; -is ~LTM.parse('aaa', :rule('cap2')), 'aaa', 'Named captures do not terminate LTM'; -is ~LTM.parse('aaa', :rule('ass1')), 'aaa', ' does not terminate LTM'; -is ~LTM.parse('aaa', :rule('ass2')), 'aaa', ' does not terminate LTM'; +is ~LTM.subparse('foobar', :rule('lit')), 'foobar', 'LTM picks longest literal'; +is ~LTM.subparse('1.2', :rule('cclass1')), '1.2', 'LTM picks longest with char classes'; +is ~LTM.subparse('1.2', :rule('cclass2')), '1.2', '...and it not just luck with ordering'; +is ~LTM.subparse('11', :rule('cclass3')), '11', 'LTM works with things like \d'; +is ~LTM.subparse('..', :rule('cclass4')), '..', '...and negated ones like \W'; +is ~LTM.subparse('ab', :rule('quant1')), 'ab', 'LTM and ? quantifier'; +is ~LTM.subparse('abbb', :rule('quant2')), 'abbb', 'LTM, ? and + quantifiers'; +is ~LTM.subparse('aaaa', :rule('quant3')), 'aaaa', 'LTM and * quantifier'; +is ~LTM.subparse('aaa', :rule('declok')), 'aaa', ':my declarations do not terminate LTM'; +is ~LTM.subparse('aaa', :rule('cap1')), 'aaa', 'Positional captures do not terminate LTM'; +is ~LTM.subparse('aaa', :rule('cap2')), 'aaa', 'Named captures do not terminate LTM'; +is ~LTM.subparse('aaa', :rule('ass1')), 'aaa', ' does not terminate LTM'; +is ~LTM.subparse('aaa', :rule('ass2')), 'aaa', ' does not terminate LTM'; #?niecza todo '#89' -is ~LTM.parse('aaa', :rule('block')), 'aa', 'However, code blocks do terminate LTM'; +is ~LTM.subparse('aaa', :rule('block')), 'aa', 'However, code blocks do terminate LTM'; # RT120146 #?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 token ident {'-'?*} token num {[\+|\-]?\d+} - proto token term { <...> } + proto token term {*} token term:sym {} token term:sym {} } - is ~G.parse("-42", :rule), '-42', 'num parse'; - is ~G.parse("-my_id", :rule), '-my_id', 'id parse'; - is ~G.parse("my_id", :rule), 'my_id', 'term parse'; + is ~G.subparse("-42", :rule), '-42', 'num parse'; + is ~G.subparse("-my_id", :rule), '-my_id', 'id parse'; + is ~G.subparse("my_id", :rule), 'my_id', 'term parse'; #?rakudo todo 'RT120146' - is ~G.parse("-my_id", :rule), '-my_id', 'term parse, leading "-"'; + is ~G.subparse("-my_id", :rule), '-my_id', 'term parse, leading "-"'; } # vim: ft=perl6