@@ -14,7 +14,7 @@ be valid perl6.
14
14
15
15
# Note: single-quotes.t tests repetition on single quoted items in regexes.
16
16
17
- plan 32 ;
17
+ plan 46 ;
18
18
19
19
# L<S05/Bracket rationalization/The general repetition specifier is now>
20
20
@@ -37,6 +37,25 @@ ok(!( "abcd" ~~ m/'abc'**2..*/ ), 'Fail open range repetition');
37
37
ok (" abcabcabcabcd" ~~ m /'abc' ** { 2 .. * } /, ' Open range repetition using closure' );
38
38
ok (! ( " abcd" ~~ m /'abc' ** { 2 .. * } /), ' Fail open range repetition using closure' );
39
39
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
+
40
59
# It is illegal to return a list, so this easy mistake fails:
41
60
throws-like ' "foo" ~~ m/o{1,3}/' , X::Obsolete , ' P5-style {1,3} range mistake is caught' ;
42
61
throws-like ' "foo" ~~ m/o{1,}/' , X::Obsolete , ' P5-style {1,} range mistake is caught' ;
0 commit comments