1N/A#!./perl
1N/A
1N/ABEGIN {
1N/A chdir 't';
1N/A @INC = '../lib';
1N/A require './test.pl';
1N/A}
1N/A
1N/Aplan tests => 59;
1N/A
1N/A$a = "HELLO.* world";
1N/A$b = "hello.* WORLD";
1N/A
1N/Ais("\Q$a\E." , "HELLO\\.\\*\\ world.", '\Q\E HELLO.* world');
1N/Ais("\u$a" , "HELLO\.\* world", '\u');
1N/Ais("\l$a" , "hELLO\.\* world", '\l');
1N/Ais("\U$a" , "HELLO\.\* WORLD", '\U');
1N/Ais("\L$a" , "hello\.\* world", '\L');
1N/A
1N/Ais(quotemeta($a) , "HELLO\\.\\*\\ world", 'quotemeta');
1N/Ais(ucfirst($a) , "HELLO\.\* world", 'ucfirst');
1N/Ais(lcfirst($a) , "hELLO\.\* world", 'lcfirst');
1N/Ais(uc($a) , "HELLO\.\* WORLD", 'uc');
1N/Ais(lc($a) , "hello\.\* world", 'lc');
1N/A
1N/Ais("\Q$b\E." , "hello\\.\\*\\ WORLD.", '\Q\E hello.* WORLD');
1N/Ais("\u$b" , "Hello\.\* WORLD", '\u');
1N/Ais("\l$b" , "hello\.\* WORLD", '\l');
1N/Ais("\U$b" , "HELLO\.\* WORLD", '\U');
1N/Ais("\L$b" , "hello\.\* world", '\L');
1N/A
1N/Ais(quotemeta($b) , "hello\\.\\*\\ WORLD", 'quotemeta');
1N/Ais(ucfirst($b) , "Hello\.\* WORLD", 'ucfirst');
1N/Ais(lcfirst($b) , "hello\.\* WORLD", 'lcfirst');
1N/Ais(uc($b) , "HELLO\.\* WORLD", 'uc');
1N/Ais(lc($b) , "hello\.\* world", 'lc');
1N/A
1N/A# \x{100} is LATIN CAPITAL LETTER A WITH MACRON; its bijective lowercase is
1N/A# \x{101}, LATIN SMALL LETTER A WITH MACRON.
1N/A
1N/A$a = "\x{100}\x{101}Aa";
1N/A$b = "\x{101}\x{100}aA";
1N/A
1N/Ais("\Q$a\E." , "\x{100}\x{101}Aa.", '\Q\E \x{100}\x{101}Aa');
1N/Ais("\u$a" , "\x{100}\x{101}Aa", '\u');
1N/Ais("\l$a" , "\x{101}\x{101}Aa", '\l');
1N/Ais("\U$a" , "\x{100}\x{100}AA", '\U');
1N/Ais("\L$a" , "\x{101}\x{101}aa", '\L');
1N/A
1N/Ais(quotemeta($a) , "\x{100}\x{101}Aa", 'quotemeta');
1N/Ais(ucfirst($a) , "\x{100}\x{101}Aa", 'ucfirst');
1N/Ais(lcfirst($a) , "\x{101}\x{101}Aa", 'lcfirst');
1N/Ais(uc($a) , "\x{100}\x{100}AA", 'uc');
1N/Ais(lc($a) , "\x{101}\x{101}aa", 'lc');
1N/A
1N/Ais("\Q$b\E." , "\x{101}\x{100}aA.", '\Q\E \x{101}\x{100}aA');
1N/Ais("\u$b" , "\x{100}\x{100}aA", '\u');
1N/Ais("\l$b" , "\x{101}\x{100}aA", '\l');
1N/Ais("\U$b" , "\x{100}\x{100}AA", '\U');
1N/Ais("\L$b" , "\x{101}\x{101}aa", '\L');
1N/A
1N/Ais(quotemeta($b) , "\x{101}\x{100}aA", 'quotemeta');
1N/Ais(ucfirst($b) , "\x{100}\x{100}aA", 'ucfirst');
1N/Ais(lcfirst($b) , "\x{101}\x{100}aA", 'lcfirst');
1N/Ais(uc($b) , "\x{100}\x{100}AA", 'uc');
1N/Ais(lc($b) , "\x{101}\x{101}aa", 'lc');
1N/A
1N/A# \x{DF} is LATIN SMALL LETTER SHARP S, its uppercase is SS or \x{53}\x{53};
1N/A# \x{149} is LATIN SMALL LETTER N PRECEDED BY APOSTROPHE, its uppercase is
1N/A# \x{2BC}\x{E4} or MODIFIER LETTER APOSTROPHE and N.
1N/A
1N/A# In EBCDIC \x{DF} is LATIN SMALL LETTER Y WITH DIAERESIS,
1N/A# and it's uppercase is \x{178}, LATIN CAPITAL LETTER Y WITH DIAERESIS.
1N/A
1N/Aif (ord("A") == 193) { # EBCDIC
1N/A is("\U\x{DF}aB\x{149}cD" , "\x{178}AB\x{2BC}NCD",
1N/A "multicharacter uppercase");
1N/A} elsif (ord("A") == 65) {
1N/A is("\U\x{DF}aB\x{149}cD" , "SSAB\x{2BC}NCD",
1N/A "multicharacter uppercase");
1N/A} else {
1N/A fail("what is your encoding?");
1N/A}
1N/A
1N/A# The \x{DF} is its own lowercase, ditto for \x{149}.
1N/A# There are no single character -> multiple characters lowercase mappings.
1N/A
1N/Aif (ord("A") == 193) { # EBCDIC
1N/A is("\LaB\x{149}cD" , "ab\x{149}cd",
1N/A "multicharacter lowercase");
1N/A} elsif (ord("A") == 65) {
1N/A is("\L\x{DF}aB\x{149}cD" , "\x{DF}ab\x{149}cd",
1N/A "multicharacter lowercase");
1N/A} else {
1N/A fail("what is your encoding?");
1N/A}
1N/A
1N/A# titlecase is used for \u / ucfirst.
1N/A
1N/A# \x{587} is ARMENIAN SMALL LIGATURE ECH YIWN and its titlecase is
1N/A# \x{535}\x{582} ARMENIAN CAPITAL LETTER ECH + ARMENIAN SMALL LETTER YIWN
1N/A# while its lowercase is
1N/A# \x{587} itself
1N/A# and its uppercase is
1N/A# \x{535}\x{552} ARMENIAN CAPITAL LETTER ECH + ARMENIAN CAPITAL LETTER YIWN
1N/A
1N/A$a = "\x{587}";
1N/A
1N/Ais("\L\x{587}" , "\x{587}", "ligature lowercase");
1N/Ais("\u\x{587}" , "\x{535}\x{582}", "ligature titlecase");
1N/Ais("\U\x{587}" , "\x{535}\x{552}", "ligature uppercase");
1N/A
1N/A# mktables had problems where many-to-one case mappings didn't work right.
1N/A# The lib/unifold.t should give the fourth folding, "casefolding", a good
1N/A# workout.
1N/A# \x{01C4} is LATIN CAPITAL LETTER DZ WITH CARON
1N/A# \x{01C5} is LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON
1N/A# \x{01C6} is LATIN SMALL LETTER DZ WITH CARON
1N/A# \x{03A3} is GREEK CAPITAL LETTER SIGMA
1N/A# \x{03C2} is GREEK SMALL LETTER FINAL SIGMA
1N/A# \x{03C3} is GREEK SMALL LETTER SIGMA
1N/A
1N/Ais(lc("\x{1C4}") , "\x{1C6}", "U+01C4 lc is U+01C6");
1N/Ais(lc("\x{1C5}") , "\x{1C6}", "U+01C5 lc is U+01C6, too");
1N/A
1N/Ais(ucfirst("\x{3C2}") , "\x{3A3}", "U+03C2 ucfirst is U+03A3");
1N/Ais(ucfirst("\x{3C3}") , "\x{3A3}", "U+03C3 ucfirst is U+03A3, too");
1N/A
1N/Ais(uc("\x{1C5}") , "\x{1C4}", "U+01C5 uc is U+01C4");
1N/Ais(uc("\x{1C6}") , "\x{1C4}", "U+01C6 uc is U+01C4, too");
1N/A
1N/A# #18107: A host of bugs involving [ul]c{,first}. AMS 20021106
1N/A$a = "\x{3c3}foo.bar"; # \x{3c3} == GREEK SMALL LETTER SIGMA.
1N/A$b = "\x{3a3}FOO.BAR"; # \x{3a3} == GREEK CAPITAL LETTER SIGMA.
1N/A
1N/A($c = $b) =~ s/(\w+)/lc($1)/ge;
1N/Ais($c , $a, "Using s///e to change case.");
1N/A
1N/A($c = $a) =~ s/(\w+)/uc($1)/ge;
1N/Ais($c , $b, "Using s///e to change case.");
1N/A
1N/A($c = $b) =~ s/(\w+)/lcfirst($1)/ge;
1N/Ais($c , "\x{3c3}FOO.bAR", "Using s///e to change case.");
1N/A
1N/A($c = $a) =~ s/(\w+)/ucfirst($1)/ge;
1N/Ais($c , "\x{3a3}foo.Bar", "Using s///e to change case.");
1N/A
1N/A# #18931: perl5.8.0 bug in \U..\E processing
1N/A# Test case from Nick Clark.
1N/Afor my $a (0,1) {
1N/A $_ = 'abcdefgh';
1N/A $_ .= chr 256;
1N/A chop;
1N/A /(.*)/;
1N/A is(uc($1), "ABCDEFGH", "[perl #18931]");
1N/A}
1N/A
1N/A{
1N/A foreach (0, 1) {
1N/A $a = v10.v257;
1N/A chop $a;
1N/A $a =~ s/^(\s*)(\w*)/$1\u$2/;
1N/A is($a, v10, "[perl #18857]");
1N/A $test++;
1N/A }
1N/A}