Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 52 lines (37 sloc) 2.005 kb
6477312 [gsoc_spectest] moved repeat.t into spec, added more tests (added 11 …
Auzon authored
1 use v6;
2
3 use Test;
4
5 =begin pod
6
7 This file was derived from the perl5 CPAN module Perl6::Rules,
8 version 0.3 (12 Apr 2004), file t/repeat.t.
9
10 It has (hopefully) been, and should continue to be, updated to
11 be valid perl6.
12
13 =end pod
14
15 # Note: single-quotes.t tests repetition on single quoted items in regexes.
16
17 plan 17;
18
19 # L<S05/Bracket rationalization/The general repetition specifier is now>
20
21 # Exact repetition
22 ok("abcabcabcabcd" ~~ m/[abc]**4/, 'Fixed exact repetition');
1c03036 Fixing a minor bug and adding rakudo skips
baest authored
23 ok(!("abcabcabcabcd" ~~ m/[abc]**5/), 'Fail fixed exact repetition');
6477312 [gsoc_spectest] moved repeat.t into spec, added more tests (added 11 …
Auzon authored
24 #?pugs todo force_todo
25 ok("abcabcabcabcd" ~~ m/[abc]**{4}/, 'Fixed exact repetition using closure');
26 ok(!( "abcabcabcabcd" ~~ m/[abc]**{5}/ ), 'Fail fixed exact repetition using closure');
27
28 # Closed range repetition
29 ok("abcabcabcabcd" ~~ m/[abc]**2..4/, 'Fixed range repetition');
30 ok(!( "abc" ~~ m/[abc]**2..4/ ), 'Fail fixed range repetition');
31 #?pugs todo force_todo
32 ok("abcabcabcabcd" ~~ m/[abc]**{2..4}/, 'Fixed range repetition using closure');
33 ok(!( "abc" ~~ m/[abc]**{2..4}/ ), 'Fail fixed range repetition using closure');
34
35 # Open range repetition
36 ok("abcabcabcabcd" ~~ m/[abc]**2..*/, 'Open range repetition');
37 ok(!( "abcd" ~~ m/[abc]**2..*/ ), 'Fail open range repetition');
38 #?pugs todo force_todo
39 ok("abcabcabcabcd" ~~ m/[abc]**{2..*}/, 'Open range repetition using closure');
40 ok(!( "abcd" ~~ m/[abc]**{2..*}/), 'Fail open range repetition using closure');
41
42 # It is illegal to return a list, so this easy mistake fails:
f8648bf [spec] s/dies_ok/eval_dies_ok/ in S05-metasyntax/repeat.t
moritz authored
43 eval_dies_ok('"foo" ~~ m/o{1,3}/', 'P5-style {1,3} range mistake is caught');
44 eval_dies_ok('"foo" ~~ m/o{1,}/}', 'P5-style {1,} range mistake is caught');
6477312 [gsoc_spectest] moved repeat.t into spec, added more tests (added 11 …
Auzon authored
45
46 # A successful match of such a quantifier always ends "in the middle"
382f35b [repeat.t] ** is not allowed on an already quantified atom
lwall authored
47 is(~('foo,bar,baz,' ~~ m/[<alpha>+] ** ','/), 'foo,bar,baz', '** with a term worked');
48 is(~('foo,bar,baz,' ~~ m/[<alpha>+] **? ','/), 'foo', '**? with a term worked');
49 is(~('foo, bar,' ~~ m/[<alpha>+] **[','\s*]/), 'foo, bar', '** with a more complex term');
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
50
51 # vim: ft=perl6
Something went wrong with that request. Please try again.