This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
EBCDIC fix: t/op/lc.t failures 24-25, 29-30, 34-35, 39-40
[perl5.git] / t / op / lc.t
CommitLineData
b0f2b690
JH
1#!./perl
2
2e3dedfe 3print "1..51\n";
983ffd37
JH
4
5my $test = 1;
6
7sub 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
27ok("\Q$a\E." eq "HELLO\\.\\*\\ world.", '\Q\E HELLO.* world');
28ok("\u$a" eq "HELLO\.\* world", '\u');
29ok("\l$a" eq "hELLO\.\* world", '\l');
30ok("\U$a" eq "HELLO\.\* WORLD", '\U');
31ok("\L$a" eq "hello\.\* world", '\L');
32
33ok(quotemeta($a) eq "HELLO\\.\\*\\ world", 'quotemeta');
34ok(ucfirst($a) eq "HELLO\.\* world", 'ucfirst');
35ok(lcfirst($a) eq "hELLO\.\* world", 'lcfirst');
36ok(uc($a) eq "HELLO\.\* WORLD", 'uc');
37ok(lc($a) eq "hello\.\* world", 'lc');
38
39ok("\Q$b\E." eq "hello\\.\\*\\ WORLD.", '\Q\E hello.* WORLD');
40ok("\u$b" eq "Hello\.\* WORLD", '\u');
41ok("\l$b" eq "hello\.\* WORLD", '\l');
42ok("\U$b" eq "HELLO\.\* WORLD", '\U');
43ok("\L$b" eq "hello\.\* world", '\L');
44
45ok(quotemeta($b) eq "hello\\.\\*\\ WORLD", 'quotemeta');
46ok(ucfirst($b) eq "Hello\.\* WORLD", 'ucfirst');
47ok(lcfirst($b) eq "hello\.\* WORLD", 'lcfirst');
48ok(uc($b) eq "HELLO\.\* WORLD", 'uc');
49ok(lc($b) eq "hello\.\* world", 'lc');
50
51# \x{100} is LATIN CAPITAL LETTER A WITH MACRON; its bijective lowercase is
7e965bc5 52# \x{101}, LATIN SMALL LETTER A WITH MACRON.
b0f2b690 53
2533d950
JH
54$a = "\x{100}\x{101}Aa";
55$b = "\x{101}\x{100}aA";
b0f2b690 56
2533d950
JH
57ok("\Q$a\E." eq "\x{100}\x{101}Aa.", '\Q\E \x{100}\x{101}Aa');
58ok("\u$a" eq "\x{100}\x{101}Aa", '\u');
59ok("\l$a" eq "\x{101}\x{101}Aa", '\l');
60ok("\U$a" eq "\x{100}\x{100}AA", '\U');
61ok("\L$a" eq "\x{101}\x{101}aa", '\L');
983ffd37 62
2533d950
JH
63ok(quotemeta($a) eq "\x{100}\x{101}Aa", 'quotemeta');
64ok(ucfirst($a) eq "\x{100}\x{101}Aa", 'ucfirst');
65ok(lcfirst($a) eq "\x{101}\x{101}Aa", 'lcfirst');
66ok(uc($a) eq "\x{100}\x{100}AA", 'uc');
67ok(lc($a) eq "\x{101}\x{101}aa", 'lc');
983ffd37 68
2533d950
JH
69ok("\Q$b\E." eq "\x{101}\x{100}aA.", '\Q\E \x{101}\x{100}aA');
70ok("\u$b" eq "\x{100}\x{100}aA", '\u');
71ok("\l$b" eq "\x{101}\x{100}aA", '\l');
72ok("\U$b" eq "\x{100}\x{100}AA", '\U');
73ok("\L$b" eq "\x{101}\x{101}aa", '\L');
983ffd37 74
2533d950
JH
75ok(quotemeta($b) eq "\x{101}\x{100}aA", 'quotemeta');
76ok(ucfirst($b) eq "\x{100}\x{100}aA", 'ucfirst');
77ok(lcfirst($b) eq "\x{101}\x{100}aA", 'lcfirst');
78ok(uc($b) eq "\x{100}\x{100}AA", 'uc');
79ok(lc($b) eq "\x{101}\x{101}aa", 'lc');
983ffd37
JH
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
7e965bc5 85ok("\U\x{DF}ab\x{149}cd" eq "SSAB\x{2BC}NCD",
983ffd37
JH
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
91ok("\L\x{DF}AB\x{149}CD" eq "\x{DF}ab\x{149}cd",
92 "multicharacter lowercase");
b0f2b690 93
44bc797b
JH
94# titlecase is used for \u / ucfirst.
95
96# \x{587} is ARMENIAN SMALL LIGATURE ECH YIWN and its titlecase is
97# \x{535}\x{582} ARMENIAN CAPITAL LETTER ECH + ARMENIAN SMALL LETTER YIWN
98# while its lowercase is
99# \x{587} itself
100# and its uppercase is
101# \x{535}\x{552} ARMENIAN CAPITAL LETTER ECH + ARMENIAN CAPITAL LETTER YIWN
102
103$a = "\x{587}";
104
105ok("\L\x{587}" eq "\x{587}", "ligature lowercase");
106ok("\u\x{587}" eq "\x{535}\x{582}", "ligature titlecase");
107ok("\U\x{587}" eq "\x{535}\x{552}", "ligature uppercase");
108
2e3dedfe
JH
109# mktables had problems where many-to-one case mappings didn't work right.
110# The lib/unifold.t should give the fourth folding, "casefolding", a good
111# workout.
112
113ok(lc("\x{1C4}") eq "\x{1C6}", "U+01C4 lc is U+01C6");
114ok(lc("\x{1C5}") eq "\x{1C6}", "U+01C5 lc is U+01C6, too");
115
116ok(ucfirst("\x{3C2}") eq "\x{3A3}", "U+03C2 ucfirst is U+03A3");
117ok(ucfirst("\x{3C3}") eq "\x{3A3}", "U+03C3 ucfirst is U+03A3, too");
118
119ok(uc("\x{1C5}") eq "\x{1C4}", "U+01C5 uc is U+01C4");
120ok(uc("\x{1C6}") eq "\x{1C4}", "U+01C6 uc is U+01C4, too");
121