Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

29 lines (20 sloc) 0.825 kB
use v6;
use Test;
#L<S05/Modifiers/"The new :r or :ratchet modifier">
# for other tests see
# t/spec/S05-mass/rx.t
# backtracking
regex aplus { a+ };
ok 'aaaa' ~~ m/ ^ <aplus> a $ /, 'normal regexes backtrack into subrules';
ok 'aaaa' !~~ m/ :ratchet ^ <aplus> a $ /, ' ... but not with :ratchet';
# what follows now might make your head twitch. Don't worry about that, it's
# normal. See http://irclog.perlgeek.de/perl6/2009-10-12#i_1595951 for a
# discussion
ok 'aaaa' !~~ m/ :ratchet ^ [ :!ratchet <aplus> ] a /,
'if the failing atom is outside the :!ratchet group: no backtracking';
ok 'aaaa' ~~ m/ :ratchet ^ [ :!ratchet <aplus> a ] /,
'if the failing atom is inside the :!ratchet group: backtracking';
ok 'aaaa' ~~ m/ ^ :!ratchet <aplus> :ratchet a /,
'Same if not grouped';
done;
# vim: ft=perl6
Jump to Line
Something went wrong with that request. Please try again.