Skip to content
Newer
Older
100644 95 lines (73 sloc) 3.51 KB
d3907e1 [t/spec] test .caps on Match objects
moritz authored
1 use v6;
2 use Test;
0a3a69d @jnthn Test for RT #125391.
jnthn authored
3 plan 43;
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';
1d0069f @moritz Test that Match.caps and .chunks returns something Iterable
moritz authored
16 ok $/.caps ~~ Iterable, '$/.caps returns something Iterable';
17 ok $/.chunks ~~ Iterable, '$/.chunks returns something Iterable';
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
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 values are Matches (caps);';
21 isa-ok $/.chunks.[0].value, Match, '.. and the values are Matches (chunks);';
734bc95 [t/spec]
moritz authored
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
95fa290 [t/spec] brush up caps.t, and fudge it for rakudo
moritz authored
26 my token wc { \w };
d3907e1 [t/spec] test .caps on Match objects
moritz authored
27
95fa290 [t/spec] brush up caps.t, and fudge it for rakudo
moritz authored
28 ok 'a b c' ~~ /:s <wc=&wc> (\w) <wc=&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';
55a2d53 [t/spec] adjust some Match.caps and Match.chunks tests to my new unde…
moritz authored
34 is ca($/.caps), '0:a|0:b|0:c|0:d', '[(\w)* \s*]+ flattens (...)* for .caps';
35 is ca($/.chunks), '0:a|~: |0:b|~: |0:c|~: |0:d',
734bc95 [t/spec]
moritz authored
36 '[(\w)* \s*]+ flattens (...)* for .chunks';
d3907e1 [t/spec] test .caps on Match objects
moritz authored
37
6df68e5 [caps.t] old-school cclass warning suppression
lwall authored
38 ok 'a b c' ~~ /[ (\S) \s ] ** 2 (\S)/, 'regex matches';
55a2d53 [t/spec] adjust some Match.caps and Match.chunks tests to my new unde…
moritz authored
39 is ca($/.caps), '0:a|0:b|1:c', '.caps distinguishes quantified () and multiple ()';
40 is ca($/.chunks), '0:a|~: |0:b|~: |1:c', '.chunks distinguishes quantified () and multiple ()';
41
95fa290 [t/spec] brush up caps.t, and fudge it for rakudo
moritz authored
42 ok 'a b c d' ~~ /:s [(\w) <wc=&wc> ]+/, 'regex matches';
636e4d6 @coke prefer RT #ticket
coke authored
43 #'RT #75484 (fails randomly) (noauto)'
d96889b @felliott fix and unfudge tests for RT #75484
felliott authored
44 is ca($/.caps), '0:a|wc:b|0:c|wc:d',
734bc95 [t/spec]
moritz authored
45 'mixed named/positional flattening with quantifiers';
d96889b @felliott fix and unfudge tests for RT #75484
felliott authored
46 is ca($/.chunks), '0:a|~: |wc:b|~: |0:c|~: |wc:d',
d3907e1 [t/spec] test .caps on Match objects
moritz authored
47 'mixed named/positional flattening with quantifiers';
48
594e40d [t/spec] tests .caps and .chunks on submatches
moritz authored
49 # .caps and .chunks on submatches
50
e2b35a2 [t/spec] correctet test for .chunks on submatches
moritz authored
51 ok ' abcdef' ~~ m/.*?(a(.).)/, 'Regex matches';
594e40d [t/spec] tests .caps and .chunks on submatches
moritz authored
52 is ca($0.caps), '0:b', '.caps on submatches';
e2b35a2 [t/spec] correctet test for .chunks on submatches
moritz authored
53 is ca($0.chunks), '~:a|0:b|~:c', '.chunks on submatches';
594e40d [t/spec] tests .caps and .chunks on submatches
moritz authored
54
25668e6 @coke Prefer RT #XXXXXX
coke authored
55 # RT #117831 separator captures
bc4c9a5 @dwarring tests separator captures RT #117831
dwarring authored
56 ok 'a;b,c,' ~~ m/(<.alpha>) +% (<.punct>)/, 'Regex matches';
dc63e3d @dwarring tweaked descriptions for % and %% separator tests
dwarring authored
57 is ca($/.caps), '0:a|1:;|0:b|1:,|0:c', '.caps on % separator';
58 is ca($/.chunks), '0:a|1:;|0:b|1:,|0:c', '.chunks on % separator';
bc4c9a5 @dwarring tests separator captures RT #117831
dwarring authored
59
60 ok 'a;b,c,' ~~ m/(<.alpha>) +%% (<.punct>)/, 'Regex matches';
dc63e3d @dwarring tweaked descriptions for % and %% separator tests
dwarring authored
61 is ca($/.caps), '0:a|1:;|0:b|1:,|0:c|1:,', '.caps on %% separator';
62 is ca($/.chunks), '0:a|1:;|0:b|1:,|0:c|1:,', '.chunks on %% separator';
bc4c9a5 @dwarring tests separator captures RT #117831
dwarring authored
63
5604403 @coke niecza fudge
coke authored
64 #?niecza skip 'conjunctive regex terms - nyi'
9442ea7 @dwarring a little testing of conjunctive regex captures (&&)
dwarring authored
65 {
66 ok 'a' ~~ m/a && <alpha>/, 'Regex matches';
07bd0ab @dwarring more tests on regex conjunctive op (&&)
dwarring authored
67 is ca($/.caps), 'alpha:a', '.caps && - first term';
763e849 @dwarring a couple more tests + raukdo.jvm fudging
dwarring authored
68
9442ea7 @dwarring a little testing of conjunctive regex captures (&&)
dwarring authored
69 ok 'a' ~~ m/<alpha> && a/, 'Regex matches';
07bd0ab @dwarring more tests on regex conjunctive op (&&)
dwarring authored
70 is ca($/.caps), 'alpha:a', '.caps && - last term';
9442ea7 @dwarring a little testing of conjunctive regex captures (&&)
dwarring authored
71
763e849 @dwarring a couple more tests + raukdo.jvm fudging
dwarring authored
72 ok 'a' ~~ m/<alpha> & <ident>/, 'Regex matches';
c8953f2 @jnthn Fix another test sensitive to hash ordering.
jnthn authored
73 is ca($/.caps.sort(*.key)), 'alpha:a|ident:a', '.caps & - multiple terms';
763e849 @dwarring a couple more tests + raukdo.jvm fudging
dwarring authored
74
07bd0ab @dwarring more tests on regex conjunctive op (&&)
dwarring authored
75 ok 'a' ~~ m/<alpha> && <ident>/, 'Regex matches';
c8953f2 @jnthn Fix another test sensitive to hash ordering.
jnthn authored
76 is ca($/.caps.sort(*.key)), 'alpha:a|ident:a', '.caps && - multiple terms';
07bd0ab @dwarring more tests on regex conjunctive op (&&)
dwarring authored
77
78 ok 'ab' ~~ m/([a|b] && <alpha>)**1..2/, 'Regex matches';
79 is ca($/.caps), '0:a|0:b', '.caps on quantified &&';
80
81 ok 'ab' ~~ m/[[a|b] && <alpha>]**1..2/, 'Regex matches';
82 is ca($/.caps), 'alpha:a|alpha:b', '.caps on quantified &&';
9442ea7 @dwarring a little testing of conjunctive regex captures (&&)
dwarring authored
83 }
84
0a3a69d @jnthn Test for RT #125391.
jnthn authored
85 # RT #125391
86 {
87 my grammar Gram {
88 regex TOP { ('XX')+ %% $<delim>=<[a..z]>* }
89 }
90 is Gram.parse('XXXXXX').caps.map(*.key), (0, "delim", 0, "delim", 0, "delim"),
91 '.caps respects order of matching even with zero-width delimeters';
92 }
93
d3907e1 [t/spec] test .caps on Match objects
moritz authored
94 # vim: ft=perl6
Something went wrong with that request. Please try again.