Skip to content

Commit ece56f1

Browse files
committed
Add tr/// tests
The existing offerings had just a couple of tests, none of which tested adverbs. Closes rakudo/rakudo#1310
1 parent fc03f3b commit ece56f1

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
use v6;
2+
use lib <t/spec/packages/>;
3+
use Test;
4+
use Test::Util;
5+
6+
# Tests for tr/// transliteration operator
7+
8+
plan 12;
9+
10+
throws-like { with 'meows' { tr/eox/EOX/ } }, X::Assignment::RO,
11+
'tr///, read-only $_complains';
12+
13+
subtest 'tr///' => { plan 2;
14+
temp $_ = 'meows';
15+
is-deeply tr/eox/EOX/, StrDistance.new(:before<meows>, :after<mEOws>),
16+
'return value';
17+
is-deeply $_, 'mEOws', '$_ has updated value';
18+
}
19+
20+
subtest 'tr:d///' => { plan 2;
21+
temp $_ = 'meows';
22+
is-deeply tr:d/eox/E/, StrDistance.new(:before<meows>, :after<mEws>),
23+
'return value';
24+
is-deeply $_, 'mEws', '$_ has updated value';
25+
}
26+
27+
subtest 'tr:delete///' => { plan 2;
28+
temp $_ = 'meows';
29+
is-deeply tr:delete/eow/EO/, StrDistance.new(:before<meows>, :after<mEOs>),
30+
'return value';
31+
is-deeply $_, 'mEOs', '$_ has updated value';
32+
}
33+
34+
subtest 'tr:c///' => { plan 2;
35+
temp $_ = 'meows';
36+
is-deeply tr:c/ew/E/, StrDistance.new(:before<meows>, :after<EeEwE>),
37+
'return value';
38+
is-deeply $_, 'EeEwE', '$_ has updated value';
39+
}
40+
41+
subtest 'tr:complement///' => { plan 2;
42+
temp $_ = 'meows';
43+
is-deeply tr:complement/ew/E/,
44+
StrDistance.new(:before<meows>, :after<EeEwE>), 'return value';
45+
is-deeply $_, 'EeEwE', '$_ has updated value';
46+
}
47+
48+
subtest 'tr:s///' => { plan 2;
49+
temp $_ = 'meeeeooowwweeees';
50+
is-deeply tr:s/ew/E/,
51+
StrDistance.new(:before<meeeeooowwweeees>, :after<mEoooEs>),
52+
'return value';
53+
is-deeply $_, 'mEoooEs', '$_ has updated value';
54+
}
55+
56+
subtest 'tr:squash///' => { plan 2;
57+
temp $_ = 'meeeeooowwweeees';
58+
is-deeply tr:squash/ewZ/EWXY/,
59+
StrDistance.new(:before<meeeeooowwweeees>, :after<mEoooWEs>),
60+
'return value';
61+
is-deeply $_, 'mEoooWEs', '$_ has updated value';
62+
}
63+
64+
subtest 'tr:d:c///' => { plan 2;
65+
temp $_ = 'meeeeooowwweeees';
66+
is-deeply tr:d:c/ewZ//,
67+
StrDistance.new(:before<meeeeooowwweeees>, :after<eeeewwweeee>),
68+
'return value';
69+
is-deeply $_, 'eeeewwweeee', '$_ has updated value';
70+
}
71+
72+
subtest 'tr:d:s///' => { plan 2;
73+
temp $_ = 'meeeeooowwweeees';
74+
is-deeply tr:d:s/ewZ/EWXY/,
75+
StrDistance.new(:before<meeeeooowwweeees>, :after<mEoooWEs>),
76+
'return value';
77+
is-deeply $_, 'mEoooWEs', '$_ has updated value';
78+
}
79+
80+
subtest 'tr:c:s///' => { plan 2;
81+
temp $_ = 'meeeeooowwweeees';
82+
is-deeply tr:c:s/owZ/E/,
83+
StrDistance.new(:before<meeeeooowwweeees>, :after<EooowwwE>),
84+
'return value';
85+
is-deeply $_, 'EooowwwE', '$_ has updated value';
86+
}
87+
88+
subtest 'tr:d:c:s///' => { plan 2;
89+
temp $_ = 'meeeeooowwweeees';
90+
is-deeply tr:d:c:s/ewZ//,
91+
StrDistance.new(:before<meeeeooowwweeees>, :after<eeeewwweeee>),
92+
'return value';
93+
is-deeply $_, 'eeeewwweeee', '$_ has updated value';
94+
}
95+
96+
# vim: ft=perl6

0 commit comments

Comments
 (0)