Skip to content

Commit 5280a11

Browse files
committed
Test Str.parse-names routine
Rakudo implementation: rakudo/rakudo#1031
1 parent 1f5dead commit 5280a11

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

S32-str/parse-names.t

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
use v6;
2+
use Test;
3+
4+
plan 10 * 2;
5+
6+
for &parse-names, Str.^lookup('parse-names') -> &pn {
7+
my $t = " ({&pn.^name.lc} form)";
8+
9+
is-deeply &pn(''), '', "empty tring $t";
10+
11+
is-deeply &pn( 'BELL' ), "\c[BELL]", "one char $t";
12+
is-deeply &pn(' BELL '), "\c[BELL]",
13+
"one char with whitespace around it $t";
14+
15+
is-deeply &pn( 'BELL, BLACK HEART SUIT' ), "\c[BELL]♥", "two chars $t";
16+
is-deeply &pn(' BELL , BLACK HEART SUIT '), "\c[BELL]♥",
17+
"two chars with whitespace around $t";
18+
19+
throws-like &pn(' BELL, ' ), X::Str::InvalidCharName,
20+
'trailing comma';
21+
throws-like &pn(' ,BELL ' ), X::Str::InvalidCharName,
22+
'prefixed comma';
23+
throws-like &pn('MEOWS PERL6 IS AWESOME'), X::Str::InvalidCharName,
24+
'unknown name';
25+
throws-like &pn('MEOWS, BELL' ), X::Str::InvalidCharName,
26+
'unknown name + known name';
27+
throws-like &pn('BELL, MEOWS' ), X::Str::InvalidCharName,
28+
'known name + unknown name';
29+
}
30+
31+
# vim: ft=perl6

0 commit comments

Comments
 (0)