-
Notifications
You must be signed in to change notification settings - Fork 135
/
ii.t
75 lines (64 loc) · 2.23 KB
/
ii.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use v6;
use Test;
plan 23;
#L<S05/Modifiers/"The :ii">
# target, substution, result
my @tests = (
['Hello', 'foo', 'Foo'],
['hEllo', 'foo', 'fOo'],
['A', 'foo', 'FOO'],
['AA', 'foo', 'FOO'],
['a b', 'FOO', 'fOo'],
['a b', 'FOOB', 'fOob'],
['Ab ', 'ABCDE', 'AbCDE'],
# someone with more spec-fu please check the next two tests:
['aB ', 'abcde', 'aBcde'],
['aB ', 'ABCDE', 'aBCDE'],
);
for @tests -> $t {
my $test_str = $t[0];
$test_str ~~ s:i:ii/ .* /$t[1]/;
is $test_str, $t[2], ":ii modifier: {$t[0]} ~~ s:ii/.*/{$t[1]}/ => {$t[2]}";
}
#L<S05/Modifiers/"If the pattern is matched with :sigspace">
# target, substution, result, name
my @passing = (
['HELLO', 'foo', 'FOO', 'uc()'],
['hello', 'fOo', 'foo', 'lc()'],
['he lo', 'FOOOoO', 'fooooo', 'lc()'],
['He lo', 'FOOO', 'Fooo', 'ucfrst(lc())'],
['hE LO', 'fooo', 'fOOO', 'lcfrst(uc())'],
['hE LO', 'foobar', 'fOOBAR', 'lcfrst(uc())'],
['HE LO', 'foo', 'FOO', 'uc()'],
['Ab Cd E', 'abc de ghi j', 'Abc De GHI J', 'wordcase()'],
['Ab CD', 'abc de ghi j', 'Abc DE GHI J', 'wordcase()'],
['Ab Cd', 'abc de ghi j', 'Abc De Ghi J', 'wordcase()'],
);
my @todo = (
);
for @passing -> $t {
my $test_str = $t[0];
$test_str ~~ s:i:ii:sigspace/.*/$t[1]/;
is $test_str, $t[2], ":i:ii:sigspace modifier: {$t[0]} ~~ s:ii:s/.*/{$t[1]}/ => {$t[2]}";
}
for @todo -> $t {
my $test_str = $t[0];
$test_str ~~ s:i:ii:sigspace/.*/$t[1]/;
#?rakudo todo 'NYI'
is $test_str, $t[2], ":i:ii:sigspace modifier: {$t[0]} ~~ s:ii:s/.*/{$t[1]}/ => {$t[2]}";
}
{
$_ = 'Abc';
s:ii/ab/xy/;
is $_, 'Xyc', ':ii implies :i';
}
# RT #77406
{
ok "a" ~~ m:i/:i A/,
'duplicated before-regexp modifier ":i" allowed (1)';
ok "a" ~~ m:i:i/A/,
'duplicated before-regexp modifier ":i" allowed (2)';
ok "a" ~~ m/:i:i A/,
'duplicated before-regexp modifier ":i" allowed (3)';
}
# vim: syn=perl6 sw=4 ts=4 expandtab