Skip to content

Commit

Permalink
Add tests for backtracking into alternations
Browse files Browse the repository at this point in the history
They're the bottom eight tests listed at
Raku/nqp#368
(The other ones listed there, for quantifiers,
seem to be already covered in S05-mass/rx.t)

This closes RT #130117 and #131973.
  • Loading branch information
smls committed Oct 6, 2017
1 parent 7fd6b6f commit 65a7622
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
13 changes: 12 additions & 1 deletion S05-metasyntax/longest-alternative.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 58;
plan 62;

#L<S05/Unchanged syntactic features/"While the syntax of | does not change">

Expand Down Expand Up @@ -476,4 +476,15 @@ is "abcde" ~~ / ab <![e]> cde | ab.. /, "abcde", 'negative lookahead does LTM pr
'LTM with quantifier ** 1..2 followed by something else matches correctly';
}


# L<S05/Backtracking control>

# RT #131973
{
is 'ab' ~~ / [ab | a ] b /, 'ab', 'backtrack into |';
is 'ab' ~~ / [ab | a ]: b /, Nil, 'don\'t backtrack into [ | ]:';
is 'ab' ~~ / :r [ab | a ] b /, Nil, 'don\'t backtrack into | under :r';
is 'ab' ~~ / :r [ab | a ]:! b /, 'ab', 'backtrack into [ | ]:! despite :r';
}

# vim: ft=perl6 et
13 changes: 12 additions & 1 deletion S05-metasyntax/sequential-alternation.t
@@ -1,6 +1,6 @@
use v6;
use Test;
plan 10;
plan 14;

#L<S05/New metacharacters/"As with the disjunctions | and ||">

Expand Down Expand Up @@ -34,4 +34,15 @@ plan 10;
is ~$/, 'xx', 'first ||@list alternative matches';
}


# L<S05/Backtracking control>

# RT #130117 and #131973
{
is 'ab' ~~ / [ab || a ] b /, 'ab', 'backtrack into ||';
is 'ab' ~~ / [ab || a ]: b /, Nil, 'don\'t backtrack into [ || ]:';
is 'ab' ~~ / :r [ab || a ] b /, Nil, 'don\'t backtrack into || under :r';
is 'ab' ~~ / :r [ab || a ]:! b /, 'ab', 'backtrack into [ || ]:! despite :r';
}

# vim: ft=perl6

0 comments on commit 65a7622

Please sign in to comment.