Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
[nqp]: Add some simple protoregex tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmichaud committed Oct 28, 2009
1 parent c571f83 commit eb5ffe7
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions t/nqp/32-protoregex.t
@@ -0,0 +1,32 @@
#! nqp

# test protoregexes in grammars

plan(6);

grammar ABC {

token TOP { <symbols> .* }

proto token symbols { <...> }

token symbols:sym<abc> { <sym> }
token symbols:sym<a> { <sym> }
token symbols:sym<bang> { $<sym>=['!'] }
token symbols:sym<===> { <sym> }
}


my $/ := ABC.parse('abcdef');
ok( ?$/ , 'successfully matched grammar' );
ok( $/ eq 'abcdef', 'successful string match' );
ok( $<symbols> eq 'abc', 'successful protoregex match');
ok( $<symbols><sym> eq 'abc', 'correct proto candidate match' );

$/ := ABC.parse('adef');
ok( ?$/ , 'successfully matched grammar' );

$/ := ABC.parse('xxx');
ok( !$/ , 'successfully failed protoregex match' );


0 comments on commit eb5ffe7

Please sign in to comment.