Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 52 lines (40 sloc) 1.792 kB
d3907e1 [t/spec] test .caps on Match objects
moritz authored
1 use v6;
2 use Test;
594e40d [t/spec] tests .caps and .chunks on submatches
moritz authored
3 plan 21;
d3907e1 [t/spec] test .caps on Match objects
moritz authored
4
5 # L<S05/Match objects/"$/.caps">
6
734bc95 [t/spec]
moritz authored
7 sub ca(@x) {
8 join '|', gather {
9 for @x -> $p {
10 take $p.key ~ ':' ~ $p.value;
11 }
12 }
13 }
14
d3907e1 [t/spec] test .caps on Match objects
moritz authored
15 ok 'a b c d' ~~ /(.*)/, 'basic sanity';
734bc95 [t/spec]
moritz authored
16 isa_ok $/.caps, List, '$/.caps returns a List';
17 isa_ok $/.chunks, List, '$/.chunks returns a List';
18 isa_ok $/.caps.[0], Pair, '.. and the items are Pairs (caps);';
19 isa_ok $/.chunks.[0], Pair, '.. and the items are Pairs (chunks);';
20 isa_ok $/.caps.[0].value, Match, '.. and the items are Matches (caps);';
21 isa_ok $/.chunks.[0].value, Match, '.. and the items are Matches (chunks);';
22
23 is ca($/.caps), '0:a b c d', '$/.caps is one item for (.*)';
24 is ca($/.chunks), '0:a b c d', '$/.chunks is one item for (.*)';
d3907e1 [t/spec] test .caps on Match objects
moritz authored
25
26 token wc { \w };
27
28 ok 'a b c' ~~ /:s <wc> (\w) <wc> /, 'regex matches';
734bc95 [t/spec]
moritz authored
29 is ca($/.caps), 'wc:a|0:b|wc:c', 'named and positional captures mix correctly';
15abe33 [t/spec] fix and unfudge caps.t (I wrote half of that with Perl 5 in …
moritz authored
30 is ca($/.chunks), 'wc:a|~: |0:b|~: |wc:c',
734bc95 [t/spec]
moritz authored
31 'named and positional captures mix correctly (chunks)';
d3907e1 [t/spec] test .caps on Match objects
moritz authored
32
05e332f [t/spec] corrected caps.t, (j y)++
moritz authored
33 ok 'a b c d' ~~ /[(\w) \s*]+/, 'regex matches';
15abe33 [t/spec] fix and unfudge caps.t (I wrote half of that with Perl 5 in …
moritz authored
34 is ca($/.caps), '0:a|1:b|2:c|3:d', '[(\w)* \s*]+ flattens (...)* for .caps';
35 is ca($/.chunks), '0:a|~: |1:b|~: |2:c|~: |3:d',
734bc95 [t/spec]
moritz authored
36 '[(\w)* \s*]+ flattens (...)* for .chunks';
d3907e1 [t/spec] test .caps on Match objects
moritz authored
37
38 ok 'a b c d' ~~ /:s [(\w) <wc> ]+/, 'regex matches';
15abe33 [t/spec] fix and unfudge caps.t (I wrote half of that with Perl 5 in …
moritz authored
39 is ca($/.caps), '0:a|wc:b|1:c|wc:d',
734bc95 [t/spec]
moritz authored
40 'mixed named/positional flattening with quantifiers';
15abe33 [t/spec] fix and unfudge caps.t (I wrote half of that with Perl 5 in …
moritz authored
41 is ca($/.chunks), '0:a|~: |wc:b|~: |1:c|~: |wc:d',
d3907e1 [t/spec] test .caps on Match objects
moritz authored
42 'mixed named/positional flattening with quantifiers';
43
594e40d [t/spec] tests .caps and .chunks on submatches
moritz authored
44 # .caps and .chunks on submatches
45
46 ok ' abc' ~~ m/.*?(a(.).)/, 'Regex matches';
47 is ca($0.caps), '0:b', '.caps on submatches';
48 #?rakudo todo '.chunks on submatches'
49 is ca($0.chunks), '0:b|~:c', '.chunks on submatches';
50
d3907e1 [t/spec] test .caps on Match objects
moritz authored
51 # vim: ft=perl6
Something went wrong with that request. Please try again.