Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 37 lines (22 sloc) 0.824 kb
eb5ffe7 @pmichaud [nqp]: Add some simple protoregex tests.
pmichaud authored
1 #! nqp
2
3 # test protoregexes in grammars
4
88757e9 @pmichaud Fix bug when protoregex is called directly from Grammar.parse (Coke++)
pmichaud authored
5 plan(7);
eb5ffe7 @pmichaud [nqp]: Add some simple protoregex tests.
pmichaud authored
6
7 grammar ABC {
8
9 token TOP { <symbols> .* }
10
11 proto token symbols { <...> }
12
13 token symbols:sym<abc> { <sym> }
14 token symbols:sym<a> { <sym> }
15 token symbols:sym<bang> { $<sym>=['!'] }
16 token symbols:sym<===> { <sym> }
17 }
18
19
20 my $/ := ABC.parse('abcdef');
21 ok( ?$/ , 'successfully matched grammar' );
22 ok( $/ eq 'abcdef', 'successful string match' );
23 ok( $<symbols> eq 'abc', 'successful protoregex match');
24 ok( $<symbols><sym> eq 'abc', 'correct proto candidate match' );
25
26 $/ := ABC.parse('adef');
27 ok( ?$/ , 'successfully matched grammar' );
28
29 $/ := ABC.parse('xxx');
30 ok( !$/ , 'successfully failed protoregex match' );
31
88757e9 @pmichaud Fix bug when protoregex is called directly from Grammar.parse (Coke++)
pmichaud authored
32 $/ := ABC.parse('xxx', :rule<symbols>);
33 ok( !$/ , 'successfully failed protoregex match' );
34
35
eb5ffe7 @pmichaud [nqp]: Add some simple protoregex tests.
pmichaud authored
36
Something went wrong with that request. Please try again.