Commit | Line | Data |
---|---|---|
b0f2b690 JH |
1 | #!./perl |
2 | ||
983ffd37 JH |
3 | print "1..42\n"; |
4 | ||
5 | my $test = 1; | |
6 | ||
7 | sub ok { | |
8 | if ($_[0]) { | |
9 | if ($_[1]) { | |
10 | print "ok $test - $_[1]\n"; | |
11 | } else { | |
12 | print "ok $test\n"; | |
13 | } | |
14 | } else { | |
15 | if ($_[1]) { | |
16 | print "not ok $test - $_[1]\n"; | |
17 | } else { | |
18 | print "not ok $test\n"; | |
19 | } | |
20 | } | |
21 | $test++; | |
22 | } | |
b0f2b690 JH |
23 | |
24 | $a = "HELLO.* world"; | |
25 | $b = "hello.* WORLD"; | |
26 | ||
983ffd37 JH |
27 | ok("\Q$a\E." eq "HELLO\\.\\*\\ world.", '\Q\E HELLO.* world'); |
28 | ok("\u$a" eq "HELLO\.\* world", '\u'); | |
29 | ok("\l$a" eq "hELLO\.\* world", '\l'); | |
30 | ok("\U$a" eq "HELLO\.\* WORLD", '\U'); | |
31 | ok("\L$a" eq "hello\.\* world", '\L'); | |
32 | ||
33 | ok(quotemeta($a) eq "HELLO\\.\\*\\ world", 'quotemeta'); | |
34 | ok(ucfirst($a) eq "HELLO\.\* world", 'ucfirst'); | |
35 | ok(lcfirst($a) eq "hELLO\.\* world", 'lcfirst'); | |
36 | ok(uc($a) eq "HELLO\.\* WORLD", 'uc'); | |
37 | ok(lc($a) eq "hello\.\* world", 'lc'); | |
38 | ||
39 | ok("\Q$b\E." eq "hello\\.\\*\\ WORLD.", '\Q\E hello.* WORLD'); | |
40 | ok("\u$b" eq "Hello\.\* WORLD", '\u'); | |
41 | ok("\l$b" eq "hello\.\* WORLD", '\l'); | |
42 | ok("\U$b" eq "HELLO\.\* WORLD", '\U'); | |
43 | ok("\L$b" eq "hello\.\* world", '\L'); | |
44 | ||
45 | ok(quotemeta($b) eq "hello\\.\\*\\ WORLD", 'quotemeta'); | |
46 | ok(ucfirst($b) eq "Hello\.\* WORLD", 'ucfirst'); | |
47 | ok(lcfirst($b) eq "hello\.\* WORLD", 'lcfirst'); | |
48 | ok(uc($b) eq "HELLO\.\* WORLD", 'uc'); | |
49 | ok(lc($b) eq "hello\.\* world", 'lc'); | |
50 | ||
51 | # \x{100} is LATIN CAPITAL LETTER A WITH MACRON; its bijective lowercase is | |
52 | # \x{100}, LATIN SMALL LETTER A WITH MACRON. | |
b0f2b690 JH |
53 | |
54 | $a = "\x{100}\x{101}\x{41}\x{61}"; | |
55 | $b = "\x{101}\x{100}\x{61}\x{41}"; | |
56 | ||
983ffd37 JH |
57 | ok("\Q$a\E." eq "\x{100}\x{101}\x{41}\x{61}.", '\Q\E \x{100}\x{101}\x{41}\x{61}'); |
58 | ok("\u$a" eq "\x{100}\x{101}\x{41}\x{61}", '\u'); | |
59 | ok("\l$a" eq "\x{101}\x{101}\x{41}\x{61}", '\l'); | |
60 | ok("\U$a" eq "\x{100}\x{100}\x{41}\x{41}", '\U'); | |
61 | ok("\L$a" eq "\x{101}\x{101}\x{61}\x{61}", '\L'); | |
62 | ||
63 | ok(quotemeta($a) eq "\x{100}\x{101}\x{41}\x{61}", 'quotemeta'); | |
64 | ok(ucfirst($a) eq "\x{100}\x{101}\x{41}\x{61}", 'ucfirst'); | |
65 | ok(lcfirst($a) eq "\x{101}\x{101}\x{41}\x{61}", 'lcfirst'); | |
66 | ok(uc($a) eq "\x{100}\x{100}\x{41}\x{41}", 'uc'); | |
67 | ok(lc($a) eq "\x{101}\x{101}\x{61}\x{61}", 'lc'); | |
68 | ||
69 | ok("\Q$b\E." eq "\x{101}\x{100}\x{61}\x{41}.", '\Q\E \x{101}\x{100}\x{61}\x{41}'); | |
70 | ok("\u$b" eq "\x{100}\x{100}\x{61}\x{41}", '\u'); | |
71 | ok("\l$b" eq "\x{101}\x{100}\x{61}\x{41}", '\l'); | |
72 | ok("\U$b" eq "\x{100}\x{100}\x{41}\x{41}", '\U'); | |
73 | ok("\L$b" eq "\x{101}\x{101}\x{61}\x{61}", '\L'); | |
74 | ||
75 | ok(quotemeta($b) eq "\x{101}\x{100}\x{61}\x{41}", 'quotemeta'); | |
76 | ok(ucfirst($b) eq "\x{100}\x{100}\x{61}\x{41}", 'ucfirst'); | |
77 | ok(lcfirst($b) eq "\x{101}\x{100}\x{61}\x{41}", 'lcfirst'); | |
78 | ok(uc($b) eq "\x{100}\x{100}\x{41}\x{41}", 'uc'); | |
79 | ok(lc($b) eq "\x{101}\x{101}\x{61}\x{61}", 'lc'); | |
80 | ||
81 | # \x{DF} is LATIN SMALL LETTER SHARP S, its uppercase is SS or \x{53}\x{53}; | |
82 | # \x{149} is LATIN SMALL LETTER N PRECEDED BY APOSTROPHE, its uppercase is | |
83 | # \x{2BC}\x{E4} or MODIFIER LETTER APOSTROPHE and N. | |
84 | ||
85 | ok("\U\x{DF}ab\x{149}cd" eq "\x{53}\x{53}AB\x{2BC}\x{4E}CD", | |
86 | "multicharacter uppercase"); | |
87 | ||
88 | # The \x{DF} is its own lowercase, ditto for \x{149}. | |
89 | # There are no single character -> multiple characters lowercase mappings. | |
b0f2b690 | 90 | |
983ffd37 JH |
91 | ok("\L\x{DF}AB\x{149}CD" eq "\x{DF}ab\x{149}cd", |
92 | "multicharacter lowercase"); | |
b0f2b690 | 93 |