Skip to content

Commit a2912d0

Browse files
committed
Add spectests for 1^..^10 non inclusive range quantifiers in regexs
1 parent dc98136 commit a2912d0

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

S05-metasyntax/repeat.t

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ be valid perl6.
1414

1515
# Note: single-quotes.t tests repetition on single quoted items in regexes.
1616

17-
plan 32;
17+
plan 46;
1818

1919
# L<S05/Bracket rationalization/The general repetition specifier is now>
2020

@@ -37,6 +37,25 @@ ok(!( "abcd" ~~ m/'abc'**2..*/ ), 'Fail open range repetition');
3737
ok("abcabcabcabcd" ~~ m/'abc'**{2..*}/, 'Open range repetition using closure');
3838
ok(!( "abcd" ~~ m/'abc'**{2..*}/), 'Fail open range repetition using closure');
3939

40+
# Closed non inclusive range repetition
41+
ok("abcabcabcabcd" ~~ m/'abc'**2..^5/, 'Fixed non inclusive max range repetition');
42+
ok(!( "abc" ~~ m/'abc'**2..^5/ ), 'Fail fixed non inclusive max range repetition');
43+
ok("abcabcabcabcd" ~~ m/'abc'**1^..4/, 'Fixed non inclusive min range repetition');
44+
ok(!( "abc" ~~ m/'abc'**1^..4/ ), 'Fail fixed non inclusive min range repetition');
45+
ok("abcabcabcabcd" ~~ m/'abc'**1^..^5/, 'Fixed non inclusive min & max range repetition');
46+
ok(!( "abc" ~~ m/'abc'**1^..^5/ ), 'Fail fixed non inclusive min & max range repetition');
47+
say $/;
48+
ok("abcabcabcabcd" ~~ m/'abc'**^5/, 'Fixed non inclusive max repetition');
49+
is $/, 'abc' x 4, '...with the correct capture';
50+
ok("abcabcabcabcd" ~~ m/'abc'**^2/, 'Fixed non inclusive max repetition');
51+
is $/, 'abc' x 1, '...with the correct capture';
52+
ok("babcabcabcabcd" ~~ m/'abc'**^2/, 'Fixed non inclusive max repetition');
53+
is $/, '', '...with the correct capture';
54+
55+
# Open non inclusive range repetition
56+
ok("abcabcabcabcd" ~~ m/'abc'**1^..*/, 'Open non inclusive min range repetition');
57+
ok(!( "abcd" ~~ m/'abc'**1^..*/ ), 'Fail open non inclusive min range repetition');
58+
4059
# It is illegal to return a list, so this easy mistake fails:
4160
throws-like '"foo" ~~ m/o{1,3}/', X::Obsolete, 'P5-style {1,3} range mistake is caught';
4261
throws-like '"foo" ~~ m/o{1,}/', X::Obsolete, 'P5-style {1,} range mistake is caught';

0 commit comments

Comments
 (0)