Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 30 lines (25 sloc) 1.076 kB
877780f @sorear Some more regex tests... should merge these into roast
authored
1 use Test;
2
3 {
4 "fooxbar" ~~ /x/;
5 is $/.prematch, "foo", ".prematch works";
6 is $/.postmatch, "bar", ".postmatch works";
7
8 is ("foo" ~~ /(f)/).kv.join("|"), '0|f', '.kv sees positional';
9 is ("foo" ~~ /$<x>=[f]/).kv.join("|"), 'x|f', '.kv sees names';
10 is ("foo" ~~ /(f)/).keys.join("|"), '0', '.keys sees positional';
11 is ("foo" ~~ /$<x>=[f]/).keys.join("|"), 'x', '.keys sees names';
12 is ("foo" ~~ /(f)/).values.join("|"), 'f', '.values sees positional';
13 is ("foo" ~~ /$<x>=[f]/).values.join("|"), 'f', '.values sees names';
14
15 "abcdefg" ~~ / b $<x>=[c] d (e) f /;
16 is $/.caps».key.join('|'), 'x|0', '.caps works (keys)';
17 is $/.caps».value.join('|'), 'c|e', '.caps works (values)';
18 is $/.chunks».key.join('|'), '~|x|~|0|~', '.chunks works (keys)';
19 is $/.chunks».value.join('|'), 'b|c|d|e|f', '.chunks works (values)';
20 }
21
22 {
23 "foo" ~~ /./;
24 is "+a+".subst(/\w/, { uc $/ }), '+A+', 'can use $/ in subst() arg';
25 is ~$/, 'f', '$/ restored after subst';
26 $_ = "baa5ar";
27 s/\d//;
28 is ~$/, '5', 's/// resets $/';
29 }
Something went wrong with that request. Please try again.