#!./perl
+# This file is intentionally encoded in latin-1.
+
BEGIN {
chdir 't';
@INC = '../lib';
require './test.pl';
}
-plan tests => 93;
+use feature qw( fc );
+
+plan tests => 124;
is(lc(undef), "", "lc(undef) is ''");
is(lcfirst(undef), "", "lcfirst(undef) is ''");
is(uc(undef), "", "uc(undef) is ''");
is(ucfirst(undef), "", "ucfirst(undef) is ''");
+{
+ no feature 'fc';
+ is(CORE::fc(undef), "", "fc(undef) is ''");
+ is(CORE::fc(''), "", "fc('') is ''");
+
+ local $@;
+ eval { fc("eeyup") };
+ like($@, qr/Undefined subroutine &main::fc/, "fc() throws an exception,");
+
+ {
+ use feature 'fc';
+ local $@;
+ eval { fc("eeyup") };
+ ok(!$@, "...but works after requesting the feature");
+ }
+}
+
$a = "HELLO.* world";
$b = "hello.* WORLD";
is("\l$a" , "hELLO\.\* world", '\l');
is("\U$a" , "HELLO\.\* WORLD", '\U');
is("\L$a" , "hello\.\* world", '\L');
+is("\F$a" , "hello\.\* world", '\F');
is(quotemeta($a) , "HELLO\\.\\*\\ world", 'quotemeta');
is(ucfirst($a) , "HELLO\.\* world", 'ucfirst');
is(lcfirst($a) , "hELLO\.\* world", 'lcfirst');
is(uc($a) , "HELLO\.\* WORLD", 'uc');
is(lc($a) , "hello\.\* world", 'lc');
+is(fc($a) , "hello\.\* world", 'fc');
is("\Q$b\E." , "hello\\.\\*\\ WORLD.", '\Q\E hello.* WORLD');
is("\u$b" , "Hello\.\* WORLD", '\u');
is("\l$b" , "hello\.\* WORLD", '\l');
is("\U$b" , "HELLO\.\* WORLD", '\U');
is("\L$b" , "hello\.\* world", '\L');
+is("\F$b" , "hello\.\* world", '\F');
is(quotemeta($b) , "hello\\.\\*\\ WORLD", 'quotemeta');
is(ucfirst($b) , "Hello\.\* WORLD", 'ucfirst');
is(lcfirst($b) , "hello\.\* WORLD", 'lcfirst');
is(uc($b) , "HELLO\.\* WORLD", 'uc');
is(lc($b) , "hello\.\* world", 'lc');
+is(fc($b) , "hello\.\* world", 'fc');
# \x{100} is LATIN CAPITAL LETTER A WITH MACRON; its bijective lowercase is
# \x{101}, LATIN SMALL LETTER A WITH MACRON.
+# Which is also its foldcase.
$a = "\x{100}\x{101}Aa";
$b = "\x{101}\x{100}aA";
is("\l$a" , "\x{101}\x{101}Aa", '\l');
is("\U$a" , "\x{100}\x{100}AA", '\U');
is("\L$a" , "\x{101}\x{101}aa", '\L');
+is("\F$a" , "\x{101}\x{101}aa", '\F');
is(quotemeta($a) , "\x{100}\x{101}Aa", 'quotemeta');
is(ucfirst($a) , "\x{100}\x{101}Aa", 'ucfirst');
is(lcfirst($a) , "\x{101}\x{101}Aa", 'lcfirst');
is(uc($a) , "\x{100}\x{100}AA", 'uc');
is(lc($a) , "\x{101}\x{101}aa", 'lc');
+is(fc($a) , "\x{101}\x{101}aa", 'fc');
is("\Q$b\E." , "\x{101}\x{100}aA.", '\Q\E \x{101}\x{100}aA');
is("\u$b" , "\x{100}\x{100}aA", '\u');
is("\l$b" , "\x{101}\x{100}aA", '\l');
is("\U$b" , "\x{100}\x{100}AA", '\U');
is("\L$b" , "\x{101}\x{101}aa", '\L');
+is("\F$b" , "\x{101}\x{101}aa", '\F');
is(quotemeta($b) , "\x{101}\x{100}aA", 'quotemeta');
is(ucfirst($b) , "\x{100}\x{100}aA", 'ucfirst');
is(lcfirst($b) , "\x{101}\x{100}aA", 'lcfirst');
is(uc($b) , "\x{100}\x{100}AA", 'uc');
is(lc($b) , "\x{101}\x{101}aa", 'lc');
+is(fc($b) , "\x{101}\x{101}aa", 'fc');
# \x{DF} is LATIN SMALL LETTER SHARP S, its uppercase is SS or \x{53}\x{53};
# \x{149} is LATIN SMALL LETTER N PRECEDED BY APOSTROPHE, its uppercase is
is(latin1_to_native("\L\x{DF}aB\x{149}cD"), latin1_to_native("\x{DF}ab\x{149}cd"),
"multicharacter lowercase");
+# \x{DF} is LATIN SMALL LETTER SHARP S, its foldcase is ss or \x{73}\x{73};
+# \x{149} is LATIN SMALL LETTER N PRECEDED BY APOSTROPHE, its foldcase is
+# \x{2BC}\x{6E} or MODIFIER LETTER APOSTROPHE and n.
+# Note that is this further tested in t/uni/fold.t
+
+is(latin1_to_native("\F\x{DF}aB\x{149}cD"), latin1_to_native("ssab\x{2BC}ncd"),
+ "multicharacter foldcase");
+
+
# titlecase is used for \u / ucfirst.
# \x{587} is ARMENIAN SMALL LIGATURE ECH YIWN and its titlecase is
# \x{587} itself
# and its uppercase is
# \x{535}\x{552} ARMENIAN CAPITAL LETTER ECH + ARMENIAN CAPITAL LETTER YIWN
+# The foldcase is \x{565}\x{582} ARMENIAN SMALL LETTER ECH + ARMENIAN SMALL LETTER YIWN
$a = "\x{587}";
is("\L\x{587}" , "\x{587}", "ligature lowercase");
is("\u\x{587}" , "\x{535}\x{582}", "ligature titlecase");
is("\U\x{587}" , "\x{535}\x{552}", "ligature uppercase");
+is("\F\x{587}" , "\x{565}\x{582}", "ligature foldcase");
# mktables had problems where many-to-one case mappings didn't work right.
# The lib/uni/fold.t should give the fourth folding, "casefolding", a good
-# workout (one cannot directly get that from Perl).
+# workout.
# \x{01C4} is LATIN CAPITAL LETTER DZ WITH CARON
# \x{01C5} is LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON
# \x{01C6} is LATIN SMALL LETTER DZ WITH CARON
($c = $a) =~ s/(\p{IsWord}+)/uc($1)/ge;
is($c , $b, "Using s///e to change case.");
+($c = $a) =~ s/(\p{IsWord}+)/fc($1)/ge;
+is($c , $a, "Using s///e to foldcase.");
+
($c = $b) =~ s/(\p{IsWord}+)/lcfirst($1)/ge;
is($c , "\x{3c3}FOO.bAR", "Using s///e to change case.");
is(substr(ucfirst($_), 0), ucfirst($_), "[perl #38619] ucfirst");
}
+#fc() didn't exist back then, but coverage is coverage.
+for ("a\x{100}", "ßyz\x{100}", "xyz\x{100}", "XYZ\x{100}") { # ß to Ss (different length)
+ is(substr(fc($_), 0), fc($_), "[perl #38619] fc");
+}
+
# Related to [perl #38619]
# the original report concerns PERL_MAGIC_utf8.
# these cases concern PERL_MAGIC_regex_global.
is($result, $expect, "[perl #38619]");
}
+for (map { $_ } "A\x{100}", "ABC\x{100}", "\x{100}") {
+ chop; # get ("A", "ABC", "") in utf8
+ my $return = fc($_) =~ /\G(.?)/g;
+ my $result = $return ? $1 : "not";
+ my $expect = (fc($_) =~ /(.?)/g)[0];
+ is($return, 1, "[perl #38619]");
+ is($result, $expect, "[perl #38619]");
+}
+
for (1, 4, 9, 16, 25) {
is(uc "\x{03B0}" x $_, "\x{3a5}\x{308}\x{301}" x $_,
'uc U+03B0 grows threefold');
is(lc "\x{0130}" x $_, "i\x{307}" x $_, 'lc U+0130 grows');
+
+ is(fc "\x{03B0}" x $_, "\x{3C5}\x{308}\x{301}" x $_,
+ 'fc U+03B0 grows threefold');
}
# bug #43207
is($_, "Hello");
}
+# bug #43207
+my $temp = "Hello";
+for ("$temp") {
+ fc $_;
+ is($_, "Hello");
+}
+
# new in Unicode 5.1.0
is(lc("\x{1E9E}"), "\x{df}", "lc(LATIN CAPITAL LETTER SHARP S)");
use warnings;
# re/fold_grind.t has more complex tests, but doesn't test every fold
+# This file also tests the fc() keyword.
BEGIN {
chdir 't' if -d 't';
require './test.pl';
}
+use feature 'unicode_strings';
+
binmode *STDOUT, ":utf8";
our $TODO;
plan("no_plan");
-
# Read in the official case folding definitions.
my $CF = '../lib/unicore/CaseFolding.txt';
die qq[$0: failed to open "$CF": $!\n] if ! open(my $fh, "<", $CF);
my @CF;
+my @simple_folds;
my %reverse_fold;
while (<$fh>) {
- # Skip S since we are going for 'F'ull case folding. I is obsolete starting
- # with Unicode 3.2, but leaving it in does no harm, and allows backward
- # compatibility
+ # We only use 'S' in simple folded fc(), since the regex engine uses
+ # 'F'ull case folding. I is obsolete starting with Unicode 3.2, but
+ # leaving it in does no harm, and allows backward compatibility
next unless my ($code, $type, $mapping, $name) = $_ =~
- /^([0-9A-F]+); ([CFI]); ((?:[0-9A-F]+)(?: [0-9A-F]+)*); \# (.+)/;
+ /^([0-9A-F]+); ([CFIS]); ((?:[0-9A-F]+)(?: [0-9A-F]+)*); \# (.+)/;
# Convert any 0-255 range chars to native.
$code = sprintf("%04X", ord_latin1_to_native(hex $code)) if hex $code < 0x100;
sprintf("%04X", ord_latin1_to_native(hex $_)) }
split / /, $mapping;
+ if ( $type eq "S" ) {
+ push @simple_folds, [$code, $mapping, $type, $name];
+ next;
+ }
+
push @CF, [$code, $mapping, $type, $name];
# Get the inverse fold for single-char mappings.
close($fh) or die "$0 Couldn't close $CF";
+foreach my $test_ref ( @simple_folds ) {
+ use feature 'fc';
+ my ($code, $mapping, $type, $name) = @$test_ref;
+ my $c = pack("U0U*", hex $code);
+ my $f = pack("U0U*", map { hex } split " ", $mapping);
+
+ my $against = join "", "qq{", map("\\x{$_}", split " ", $mapping), "}";
+ {
+ isnt(fc($c), $f, "$code - $name - $mapping - $type - Full casefolding, fc(\\x{$code}) ne $against");
+ isnt("\F$c", $f, "$code - $name - $mapping - $type - Full casefolding, qq{\\F\\x{$code}} ne $against");
+ }
+}
+
foreach my $test_ref (@CF) {
my ($code, $mapping, $type, $name) = @$test_ref;
my $c = pack("U0U*", hex $code);
ok eval $test, "$code - $name - $mapping - $type - $test";
}
+ {
+ # fc() tests
+ my $against = join "", "qq{", map("\\x{$_}", split " ", $mapping), "}";
+ is(CORE::fc($c), $f,
+ "$code - $name - $mapping - $type - fc(\\x{$code}) eq $against");
+ is("\F$c", $f, "$code - $name - $mapping - $type - qq{\\F\\x{$code}} eq $against");
+
+ # And here we test bytes. For [A-Za-z0-9], the fold is the same as lc under
+ # bytes. For everything else, it's the bytes that formed the original string.
+ if ( $c =~ /[A-Za-z0-9]/ ) {
+ use bytes;
+ is(CORE::fc($c), lc($c), "$code - $name - fc and use bytes, ascii");
+ } else {
+ my $copy = "" . $c;
+ utf8::encode($copy);
+ is($copy, do { use bytes; CORE::fc($c) }, "$code - $name - fc and use bytes");
+ }
+ }
# Certain tests weren't convenient to put in the list above since they are
# TODO's in multi-character folds.
if ($f_length == 1) {
}
}
+{
+ use utf8;
+ use feature qw(fc);
+ # These three come from the ICU project's test suite, more especifically
+ # http://icu.sourcearchive.com/documentation/4.4~rc1-1/strcase_8cpp-source.html
+
+ my $s = "A\N{U+00df}\N{U+00b5}\N{U+fb03}\N{U+1040C}\N{U+0130}\N{U+0131}";
+ #\N{LATIN CAPITAL LETTER A}\N{LATIN SMALL LETTER SHARP S}\N{MICRO SIGN}\N{LATIN SMALL LIGATURE FFI}\N{DESERET CAPITAL LETTER AY}\N{LATIN CAPITAL LETTER I WITH DOT ABOVE}\N{LATIN SMALL LETTER DOTLESS I}
+
+ my $f = "ass\N{U+03bc}ffi\N{U+10434}i\N{U+0307}\N{U+0131}";
+ #\N{LATIN SMALL LETTER A}\N{LATIN SMALL LETTER S}\N{LATIN SMALL LETTER S}\N{GREEK SMALL LETTER MU}\N{LATIN SMALL LETTER F}\N{LATIN SMALL LETTER F}\N{LATIN SMALL LETTER I}\N{DESERET SMALL LETTER AY}\N{LATIN SMALL LETTER I}\N{COMBINING DOT ABOVE}\N{LATIN SMALL LETTER DOTLESS I}
+
+ is(fc($s), $f, "ICU's casefold test passes");
+ is("\F$s", $f, "ICU's casefold test passes");
+
+ is( fc("aBİIıϐßffi"), "abi̇iıβssffi" );
+ is( "\FaBİIıϐßffi", "abi̇iıβssffi" );
+# TODO: {
+# local $::TODO = "turkic special cases";
+# is( fc "aBİIıϐßffi", "abiııβssffi" );
+# }
+
+ # The next batch come from http://www.devdaily.com/java/jwarehouse/lucene/contrib/icu/src/test/org/apache/lucene/analysis/icu/TestICUFoldingFilter.java.shtml
+ # Except the article got most casings wrong. Or maybe Lucene does.
+
+ is( fc("This is a test"), "this is a test" );
+ is( fc("Ruß"), "russ" );
+ is( fc("ΜΆΪΟΣ"), "μάϊοσ" );
+ is( fc("Μάϊος"), "μάϊοσ" );
+ is( fc("𐐖"), "𐐾" );
+ is( fc("r\xe9sum\xe9"), "r\xe9sum\xe9" );
+ is( fc("re\x{0301}sume\x{0301}"), "re\x{301}sume\x{301}" );
+ is( fc("ELİF"), "eli\x{307}f" );
+ is( fc("eli\x{307}f"), "eli\x{307}f");
+
+ # This batch comes from
+ # http://www.java2s.com/Open-Source/Java-Document/Internationalization-Localization/icu4j/com/ibm/icu/dev/test/lang/UCharacterCaseTest.java.htm
+ # Which uses ICU as the backend.
+
+ my @folding_mixed = (
+ "\x{61}\x{42}\x{130}\x{49}\x{131}\x{3d0}\x{df}\x{fb03}",
+ "A\x{df}\x{b5}\x{fb03}\x{1040C}\x{130}\x{131}",
+ );
+
+ my @folding_default = (
+ "\x{61}\x{62}\x{69}\x{307}\x{69}\x{131}\x{3b2}\x{73}\x{73}\x{66}\x{66}\x{69}",
+ "ass\x{3bc}ffi\x{10434}i\x{307}\x{131}",
+ );
+
+ my @folding_exclude_turkic = (
+ "\x{61}\x{62}\x{69}\x{131}\x{131}\x{3b2}\x{73}\x{73}\x{66}\x{66}\x{69}",
+ "ass\x{3bc}ffi\x{10434}i\x{131}",
+ );
+
+ is( fc($folding_mixed[1]), $folding_default[1] );
+
+ is( fc($folding_mixed[0]), $folding_default[0] );
+
+}
+
+{
+ use utf8;
+ # Table stolen from tchrist's mail in
+ # http://bugs.python.org/file23051/casing-tests.py
+ # and http://98.245.80.27/tcpc/OSCON2011/case-test.python3
+ # For reference, it's a longer version of what he posted here:
+ # http://stackoverflow.com/questions/6991038/case-insensitive-storage-and-unicode-compatibility
+
+ #Couple of repeats because I'm lazy, not tchrist's fault.
+
+ #This should probably go in t/op/lc.t
+
+ my @test_table = (
+# ORIG LC_SIMPLE TC_SIMPLE UC_SIMPLE LC_FULL TC_FULL UC_FULL FC_SIMPLE FC_TURKIC FC_FULL
+[ 'þǽr rihtes', 'þǽr rihtes', 'Þǽr Rihtes', 'ÞǼR RIHTES', 'þǽr rihtes', 'Þǽr Rihtes', 'ÞǼR RIHTES', 'þǽr rihtes', 'þǽr rihtes', 'þǽr rihtes', ],
+[ 'duȝeðlice', 'duȝeðlice', 'Duȝeðlice', 'DUȜEÐLICE', 'duȝeðlice', 'Duȝeðlice', 'DUȜEÐLICE', 'duȝeðlice', 'duȝeðlice', 'duȝeðlice', ],
+[ 'Ævar Arnfjörð Bjarmason', 'ævar arnfjörð bjarmason', 'Ævar Arnfjörð Bjarmason', 'ÆVAR ARNFJÖRÐ BJARMASON', 'ævar arnfjörð bjarmason', 'Ævar Arnfjörð Bjarmason', 'ÆVAR ARNFJÖRÐ BJARMASON', 'ævar arnfjörð bjarmason', 'ævar arnfjörð bjarmason', 'ævar arnfjörð bjarmason', ],
+[ 'Кириллица', 'кириллица', 'Кириллица', 'КИРИЛЛИЦА', 'кириллица', 'Кириллица', 'КИРИЛЛИЦА', 'кириллица', 'кириллица', 'кириллица', ],
+[ 'ij', 'ij', 'IJ', 'IJ', 'ij', 'IJ', 'IJ', 'ij', 'ij', 'ij', ],
+[ 'Van Dijke', 'van dijke', 'Van Dijke', 'VAN DIJKE', 'van dijke', 'Van Dijke', 'VAN DIJKE', 'van dijke', 'van dijke', 'van dijke', ],
+[ 'VAN DIJKE', 'van dijke', 'Van Dijke', 'VAN DIJKE', 'van dijke', 'Van Dijke', 'VAN DIJKE', 'van dijke', 'van dijke', 'van dijke', ],
+[ 'efficient', 'efficient', 'Efficient', 'EffiCIENT', 'efficient', 'Efficient', 'EFFICIENT', 'efficient', 'efficient', 'efficient', ],
+[ 'flour', 'flour', 'flour', 'flOUR', 'flour', 'Flour', 'FLOUR', 'flour', 'flour', 'flour', ],
+[ 'flour and water', 'flour and water', 'flour And Water', 'flOUR AND WATER', 'flour and water', 'Flour And Water', 'FLOUR AND WATER', 'flour and water', 'flour and water', 'flour and water', ],
+[ 'dzur', 'dzur', 'Dzur', 'DZUR', 'dzur', 'Dzur', 'DZUR', 'dzur', 'dzur', 'dzur', ],
+[ 'Dzur', 'dzur', 'Dzur', 'DZUR', 'dzur', 'Dzur', 'DZUR', 'dzur', 'dzur', 'dzur', ],
+[ 'DZUR', 'dzur', 'Dzur', 'DZUR', 'dzur', 'Dzur', 'DZUR', 'dzur', 'dzur', 'dzur', ],
+[ 'dzur mountain', 'dzur mountain', 'Dzur Mountain', 'DZUR MOUNTAIN', 'dzur mountain', 'Dzur Mountain', 'DZUR MOUNTAIN', 'dzur mountain', 'dzur mountain', 'dzur mountain', ],
+[ 'Dzur Mountain', 'dzur mountain', 'Dzur Mountain', 'DZUR MOUNTAIN', 'dzur mountain', 'Dzur Mountain', 'DZUR MOUNTAIN', 'dzur mountain', 'dzur mountain', 'dzur mountain', ],
+[ 'DZUR MOUNTAIN', 'dzur mountain', 'Dzur Mountain', 'DZUR MOUNTAIN', 'dzur mountain', 'Dzur Mountain', 'DZUR MOUNTAIN', 'dzur mountain', 'dzur mountaın', 'dzur mountain', ],
+[ 'poſt', 'poſt', 'Poſt', 'POST', 'poſt', 'Poſt', 'POST', 'post', 'post', 'post', ],
+[ 'poſt', 'poſt', 'Poſt', 'POſt', 'poſt', 'Poſt', 'POST', 'poſt', 'post', 'post', ],
+[ 'ſtop', 'ſtop', 'ſtop', 'ſtOP', 'ſtop', 'Stop', 'STOP', 'ſtop', 'stop', 'stop', ],
+[ 'tschüß', 'tschüß', 'Tschüß', 'TSCHÜß', 'tschüß', 'Tschüß', 'TSCHÜSS', 'tschüß', 'tschüss', 'tschüss', ],
+[ 'TSCHÜẞ', 'tschüß', 'Tschüß', 'TSCHÜẞ', 'tschüß', 'Tschüß', 'TSCHÜẞ', 'tschüß', 'tschüss', 'tschüss', ],
+[ 'weiß', 'weiß', 'Weiß', 'WEIß', 'weiß', 'Weiß', 'WEISS', 'weiß', 'weiss', 'weiss', ],
+[ 'WEIẞ', 'weiß', 'Weiß', 'WEIẞ', 'weiß', 'Weiß', 'WEIẞ', 'weiß', 'weıss', 'weiss', ],
+[ 'ẞIEW', 'ßiew', 'ẞiew', 'ẞIEW', 'ßiew', 'ẞiew', 'ẞIEW', 'ßiew', 'ssıew', 'ssiew', ],
+[ 'ᾲ', 'ᾲ', 'Ὰͅ', 'ᾺΙ', 'ᾲ', 'Ὰͅ', 'ᾺΙ', 'ὰι', 'ὰι', 'ὰι', ],
+[ 'Ὰι', 'ὰι', 'Ὰι', 'ᾺΙ', 'ὰι', 'Ὰι', 'ᾺΙ', 'ὰι', 'ὰι', 'ὰι', ],
+[ 'ᾺΙ', 'ὰι', 'Ὰι', 'ᾺΙ', 'ὰι', 'Ὰι', 'ᾺΙ', 'ὰι', 'ὰι', 'ὰι', ],
+[ 'ᾲ', 'ᾲ', 'ᾲ', 'ᾲ', 'ᾲ', 'Ὰͅ', 'ᾺΙ', 'ᾲ', 'ὰι', 'ὰι', ],
+[ 'Ὰͅ', 'ᾲ', 'Ὰͅ', 'ᾺΙ', 'ᾲ', 'Ὰͅ', 'ᾺΙ', 'ὰι', 'ὰι', 'ὰι', ],
+[ 'ᾺΙ', 'ὰι', 'Ὰι', 'ᾺΙ', 'ὰι', 'Ὰι', 'ᾺΙ', 'ὰι', 'ὰι', 'ὰι', ],
+[ 'ᾲ στο διάολο', 'ᾲ στο διάολο', 'ᾲ Στο Διάολο', 'ᾲ ΣΤΟ ΔΙΆΟΛΟ', 'ᾲ στο διάολο', 'Ὰͅ Στο Διάολο', 'ᾺΙ ΣΤΟ ΔΙΆΟΛΟ', 'ᾲ στο διάολο', 'ὰι στο διάολο', 'ὰι στο διάολο', ],
+[ 'ᾲ στο διάολο', 'ᾲ στο διάολο', 'Ὰͅ Στο Διάολο', 'ᾺΙ ΣΤΟ ΔΙΆΟΛΟ', 'ᾲ στο διάολο', 'Ὰͅ Στο Διάολο', 'ᾺΙ ΣΤΟ ΔΙΆΟΛΟ', 'ὰι στο διάολο', 'ὰι στο διάολο', 'ὰι στο διάολο', ],
+[ '𐐼𐐯𐑅𐐨𐑉𐐯𐐻', '𐐼𐐯𐑅𐐨𐑉𐐯𐐻', '𐐔𐐯𐑅𐐨𐑉𐐯𐐻', '𐐔𐐇𐐝𐐀𐐡𐐇𐐓', '𐐼𐐯𐑅𐐨𐑉𐐯𐐻', '𐐔𐐯𐑅𐐨𐑉𐐯𐐻', '𐐔𐐇𐐝𐐀𐐡𐐇𐐓', '𐐼𐐯𐑅𐐨𐑉𐐯𐐻', '𐐼𐐯𐑅𐐨𐑉𐐯𐐻', '𐐼𐐯𐑅𐐨𐑉𐐯𐐻', ],
+[ '𐐔𐐯𐑅𐐨𐑉𐐯𐐻', '𐐼𐐯𐑅𐐨𐑉𐐯𐐻', '𐐔𐐯𐑅𐐨𐑉𐐯𐐻', '𐐔𐐇𐐝𐐀𐐡𐐇𐐓', '𐐼𐐯𐑅𐐨𐑉𐐯𐐻', '𐐔𐐯𐑅𐐨𐑉𐐯𐐻', '𐐔𐐇𐐝𐐀𐐡𐐇𐐓', '𐐼𐐯𐑅𐐨𐑉𐐯𐐻', '𐐼𐐯𐑅𐐨𐑉𐐯𐐻', '𐐼𐐯𐑅𐐨𐑉𐐯𐐻', ],
+[ '𐐔𐐇𐐝𐐀𐐡𐐇𐐓', '𐐼𐐯𐑅𐐨𐑉𐐯𐐻', '𐐔𐐯𐑅𐐨𐑉𐐯𐐻', '𐐔𐐇𐐝𐐀𐐡𐐇𐐓', '𐐼𐐯𐑅𐐨𐑉𐐯𐐻', '𐐔𐐯𐑅𐐨𐑉𐐯𐐻', '𐐔𐐇𐐝𐐀𐐡𐐇𐐓', '𐐼𐐯𐑅𐐨𐑉𐐯𐐻', '𐐼𐐯𐑅𐐨𐑉𐐯𐐻', '𐐼𐐯𐑅𐐨𐑉𐐯𐐻', ],
+[ 'henry ⅷ', 'henry ⅷ', 'Henry Ⅷ', 'HENRY Ⅷ', 'henry ⅷ', 'Henry Ⅷ', 'HENRY Ⅷ', 'henry ⅷ', 'henry ⅷ', 'henry ⅷ', ],
+[ 'Henry Ⅷ', 'henry ⅷ', 'Henry Ⅷ', 'HENRY Ⅷ', 'henry ⅷ', 'Henry Ⅷ', 'HENRY Ⅷ', 'henry ⅷ', 'henry ⅷ', 'henry ⅷ', ],
+[ 'HENRY Ⅷ', 'henry ⅷ', 'Henry Ⅷ', 'HENRY Ⅷ', 'henry ⅷ', 'Henry Ⅷ', 'HENRY Ⅷ', 'henry ⅷ', 'henry ⅷ', 'henry ⅷ', ],
+[ 'i work at ⓚ', 'i work at ⓚ', 'I Work At Ⓚ', 'I WORK AT Ⓚ', 'i work at ⓚ', 'I Work At Ⓚ', 'I WORK AT Ⓚ', 'i work at ⓚ', 'i work at ⓚ', 'i work at ⓚ', ],
+[ 'I Work At Ⓚ', 'i work at ⓚ', 'I Work At Ⓚ', 'I WORK AT Ⓚ', 'i work at ⓚ', 'I Work At Ⓚ', 'I WORK AT Ⓚ', 'i work at ⓚ', 'ı work at ⓚ', 'i work at ⓚ', ],
+[ 'I WORK AT Ⓚ', 'i work at ⓚ', 'I Work At Ⓚ', 'I WORK AT Ⓚ', 'i work at ⓚ', 'I Work At Ⓚ', 'I WORK AT Ⓚ', 'i work at ⓚ', 'ı work at ⓚ', 'i work at ⓚ', ],
+[ 'istambul', 'istambul', 'Istambul', 'ISTAMBUL', 'istambul', 'Istambul', 'ISTAMBUL', 'istambul', 'istambul', 'istambul', ],
+[ 'i̇stanbul', 'i̇stanbul', 'İstanbul', 'İSTANBUL', 'i̇stanbul', 'İstanbul', 'İSTANBUL', 'i̇stanbul', 'i̇stanbul', 'i̇stanbul', ],
+[ 'İstanbul', 'i̇stanbul', 'İstanbul', 'İSTANBUL', 'i̇stanbul', 'İstanbul', 'İSTANBUL', 'i̇stanbul', 'ı̇stanbul', 'i̇stanbul', ],
+[ 'İSTANBUL', 'istanbul', 'İstanbul', 'İSTANBUL', 'i̇stanbul', 'İstanbul', 'İSTANBUL', 'İstanbul', 'istanbul', 'i̇stanbul', ],
+[ 'στιγμας', 'στιγμας', 'Στιγμας', 'ΣΤΙΓΜΑΣ', 'στιγμας', 'Στιγμας', 'ΣΤΙΓΜΑΣ', 'στιγμασ', 'στιγμασ', 'στιγμασ', ],
+[ 'στιγμασ', 'στιγμασ', 'Στιγμασ', 'ΣΤΙΓΜΑΣ', 'στιγμασ', 'Στιγμασ', 'ΣΤΙΓΜΑΣ', 'στιγμασ', 'στιγμασ', 'στιγμασ', ],
+[ 'ΣΤΙΓΜΑΣ', 'στιγμασ', 'Στιγμασ', 'ΣΤΙΓΜΑΣ', 'στιγμασ', 'Στιγμασ', 'ΣΤΙΓΜΑΣ', 'στιγμασ', 'στιγμασ', 'στιγμασ', ],
+[ 'ʀᴀʀᴇ', 'ʀᴀʀᴇ', 'Ʀᴀʀᴇ', 'ƦᴀƦᴇ', 'ʀᴀʀᴇ', 'Ʀᴀʀᴇ', 'ƦᴀƦᴇ', 'ʀᴀʀᴇ', 'ʀᴀʀᴇ', 'ʀᴀʀᴇ', ],
+[ 'Ʀᴀʀᴇ', 'ʀᴀʀᴇ', 'Ʀᴀʀᴇ', 'ƦᴀƦᴇ', 'ʀᴀʀᴇ', 'Ʀᴀʀᴇ', 'ƦᴀƦᴇ', 'ʀᴀʀᴇ', 'ʀᴀʀᴇ', 'ʀᴀʀᴇ', ],
+[ 'ƦᴀƦᴇ', 'ʀᴀʀᴇ', 'Ʀᴀʀᴇ', 'ƦᴀƦᴇ', 'ʀᴀʀᴇ', 'Ʀᴀʀᴇ', 'ƦᴀƦᴇ', 'ʀᴀʀᴇ', 'ʀᴀʀᴇ', 'ʀᴀʀᴇ', ],
+[ 'Ԧԧ', 'ԧԧ', 'Ԧԧ', 'ԦԦ', 'ԧԧ', 'Ԧԧ', 'ԦԦ', 'ԧԧ', 'ԧԧ', 'ԧԧ', ],
+[ 'ԧԧ', 'ԧԧ', 'Ԧԧ', 'ԦԦ', 'ԧԧ', 'Ԧԧ', 'ԦԦ', 'ԧԧ', 'ԧԧ', 'ԧԧ', ],
+[ 'Ԧԧ', 'ԧԧ', 'Ԧԧ', 'ԦԦ', 'ԧԧ', 'Ԧԧ', 'ԦԦ', 'ԧԧ', 'ԧԧ', 'ԧԧ', ],
+[ 'ԦԦ', 'ԧԧ', 'Ԧԧ', 'ԦԦ', 'ԧԧ', 'Ԧԧ', 'ԦԦ', 'ԧԧ', 'ԧԧ', 'ԧԧ', ],
+[ "þǽr rihtes", "þǽr rihtes", "Þǽr Rihtes", "ÞǼR RIHTES", "þǽr rihtes", "Þǽr Rihtes", "ÞǼR RIHTES", "þǽr rihtes", "þǽr rihtes", "þǽr rihtes", ],
+[ "duȝeðlice", "duȝeðlice", "Duȝeðlice", "DUȜEÐLICE", "duȝeðlice", "Duȝeðlice", "DUȜEÐLICE", "duȝeðlice", "duȝeðlice", "duȝeðlice", ],
+[ "Van Dijke", "van dijke", "Van Dijke", "VAN DIJKE", "van dijke", "Van Dijke", "VAN DIJKE", "van dijke", "van dijke", "van dijke", ],
+[ "fi", "fi", "fi", "fi", "fi", "Fi", "FI", "fi", "fi", "fi", ],
+[ "filesystem", "filesystem", "filesystem", "fiLESYSTEM", "filesystem", "Filesystem", "FILESYSTEM", "filesystem", "filesystem", "filesystem", ],
+[ "efficient", "efficient", "Efficient", "EffiCIENT", "efficient", "Efficient", "EFFICIENT", "efficient", "efficient", "efficient", ],
+[ "flour and water", "flour and water", "flour And Water", "flOUR AND WATER", "flour and water", "Flour And Water", "FLOUR AND WATER", "flour and water", "flour and water", "flour and water", ],
+[ "dz", "dz", "Dz", "DZ", "dz", "Dz", "DZ", "dz", "dz", "dz", ],
+[ "dzur mountain", "dzur mountain", "Dzur Mountain", "DZUR MOUNTAIN", "dzur mountain", "Dzur Mountain", "DZUR MOUNTAIN", "dzur mountain", "dzur mountain", "dzur mountain", ],
+[ "poſt", "poſt", "Poſt", "POST", "poſt", "Poſt", "POST", "post", "post", "post", ],
+[ "poſt", "poſt", "Poſt", "POſt", "poſt", "Poſt", "POST", "poſt", "post", "post", ],
+[ "ſtop", "ſtop", "ſtop", "ſtOP", "ſtop", "Stop", "STOP", "ſtop", "stop", "stop", ],
+[ "tschüß", "tschüß", "Tschüß", "TSCHÜß", "tschüß", "Tschüß", "TSCHÜSS", "tschüß", "tschüss", "tschüss", ],
+[ "TSCHÜẞ", "tschüß", "Tschüß", "TSCHÜẞ", "tschüß", "Tschüß", "TSCHÜẞ", "tschüß", "tschüss", "tschüss", ],
+[ "rußland", "rußland", "Rußland", "RUßLAND", "rußland", "Rußland", "RUSSLAND", "rußland", "russland", "russland", ],
+[ "RUẞLAND", "rußland", "Rußland", "RUẞLAND", "rußland", "Rußland", "RUẞLAND", "rußland", "russland", "russland", ],
+[ "weiß", "weiß", "Weiß", "WEIß", "weiß", "Weiß", "WEISS", "weiß", "weiss", "weiss", ],
+[ "WEIẞ", "weiß", "Weiß", "WEIẞ", "weiß", "Weiß", "WEIẞ", "weiß", "weıss", "weiss", ],
+[ "ẞIEW", "ßiew", "ẞiew", "ẞIEW", "ßiew", "ẞiew", "ẞIEW", "ßiew", "ssıew", "ssiew", ],
+[ "ͅ", "ͅ", "Ι", "Ι", "ͅ", "Ι", "Ι", "ι", "ι", "ι", ],
+[ "ᾲ", "ᾲ", "Ὰͅ", "ᾺΙ", "ᾲ", "Ὰͅ", "ᾺΙ", "ὰι", "ὰι", "ὰι", ],
+[ "Ὰι", "ὰι", "Ὰι", "ᾺΙ", "ὰι", "Ὰι", "ᾺΙ", "ὰι", "ὰι", "ὰι", ],
+[ "ᾺΙ", "ὰι", "Ὰι", "ᾺΙ", "ὰι", "Ὰι", "ᾺΙ", "ὰι", "ὰι", "ὰι", ],
+[ "ᾲ", "ᾲ", "ᾲ", "ᾲ", "ᾲ", "Ὰͅ", "ᾺΙ", "ᾲ", "ὰι", "ὰι", ],
+[ "Ὰͅ", "ᾲ", "Ὰͅ", "ᾺΙ", "ᾲ", "Ὰͅ", "ᾺΙ", "ὰι", "ὰι", "ὰι", ],
+[ "ᾺΙ", "ὰι", "Ὰι", "ᾺΙ", "ὰι", "Ὰι", "ᾺΙ", "ὰι", "ὰι", "ὰι", ],
+[ "ᾲ στο διάολο", "ᾲ στο διάολο", "ᾲ Στο Διάολο", "ᾲ ΣΤΟ ΔΙΆΟΛΟ", "ᾲ στο διάολο", "Ὰͅ Στο Διάολο", "ᾺΙ ΣΤΟ ΔΙΆΟΛΟ", "ᾲ στο διάολο", "ὰι στο διάολο", "ὰι στο διάολο", ],
+[ "ᾲ στο διάολο", "ᾲ στο διάολο", "Ὰͅ Στο Διάολο", "ᾺΙ ΣΤΟ ΔΙΆΟΛΟ", "ᾲ στο διάολο", "Ὰͅ Στο Διάολο", "ᾺΙ ΣΤΟ ΔΙΆΟΛΟ", "ὰι στο διάολο", "ὰι στο διάολο", "ὰι στο διάολο", ],
+[ "ⅷ", "ⅷ", "Ⅷ", "Ⅷ", "ⅷ", "Ⅷ", "Ⅷ", "ⅷ", "ⅷ", "ⅷ", ],
+[ "henry ⅷ", "henry ⅷ", "Henry Ⅷ", "HENRY Ⅷ", "henry ⅷ", "Henry Ⅷ", "HENRY Ⅷ", "henry ⅷ", "henry ⅷ", "henry ⅷ", ],
+[ "ⓚ", "ⓚ", "Ⓚ", "Ⓚ", "ⓚ", "Ⓚ", "Ⓚ", "ⓚ", "ⓚ", "ⓚ", ],
+[ "i work at ⓚ", "i work at ⓚ", "I Work At Ⓚ", "I WORK AT Ⓚ", "i work at ⓚ", "I Work At Ⓚ", "I WORK AT Ⓚ", "i work at ⓚ", "i work at ⓚ", "i work at ⓚ", ],
+[ "istambul", "istambul", "Istambul", "ISTAMBUL", "istambul", "Istambul", "ISTAMBUL", "istambul", "istambul", "istambul", ],
+[ "i̇stanbul", "i̇stanbul", "İstanbul", "İSTANBUL", "i̇stanbul", "İstanbul", "İSTANBUL", "i̇stanbul", "i̇stanbul", "i̇stanbul", ],
+[ "İstanbul", "i̇stanbul", "İstanbul", "İSTANBUL", "i̇stanbul", "İstanbul", "İSTANBUL", "i̇stanbul", "ı̇stanbul", "i̇stanbul", ],
+[ "İSTANBUL", "istanbul", "İstanbul", "İSTANBUL", "i̇stanbul", "İstanbul", "İSTANBUL", "İstanbul", "istanbul", "i̇stanbul", ],
+[ "στιγμας", "στιγμας", "Στιγμας", "ΣΤΙΓΜΑΣ", "στιγμας", "Στιγμας", "ΣΤΙΓΜΑΣ", "στιγμασ", "στιγμασ", "στιγμασ", ],
+[ "στιγμασ", "στιγμασ", "Στιγμασ", "ΣΤΙΓΜΑΣ", "στιγμασ", "Στιγμασ", "ΣΤΙΓΜΑΣ", "στιγμασ", "στιγμασ", "στιγμασ", ],
+[ "ΣΤΙΓΜΑΣ", "στιγμασ", "Στιγμασ", "ΣΤΙΓΜΑΣ", "στιγμασ", "Στιγμασ", "ΣΤΙΓΜΑΣ", "στιγμασ", "στιγμασ", "στιγμασ", ],
+[ "ʀᴀʀᴇ", "ʀᴀʀᴇ", "Ʀᴀʀᴇ", "ƦᴀƦᴇ", "ʀᴀʀᴇ", "Ʀᴀʀᴇ", "ƦᴀƦᴇ", "ʀᴀʀᴇ", "ʀᴀʀᴇ", "ʀᴀʀᴇ", ],
+[ "𐐼𐐯𐑅𐐨𐑉𐐯𐐻", "𐐼𐐯𐑅𐐨𐑉𐐯𐐻", "𐐔𐐯𐑅𐐨𐑉𐐯𐐻", "𐐔𐐇𐐝𐐀𐐡𐐇𐐓", "𐐼𐐯𐑅𐐨𐑉𐐯𐐻", "𐐔𐐯𐑅𐐨𐑉𐐯𐐻", "𐐔𐐇𐐝𐐀𐐡𐐇𐐓", "𐐼𐐯𐑅𐐨𐑉𐐯𐐻", "𐐼𐐯𐑅𐐨𐑉𐐯𐐻", "𐐼𐐯𐑅𐐨𐑉𐐯𐐻", ],
+[ "Ԧԧ", "ԧԧ", "Ԧԧ", "ԦԦ", "ԧԧ", "Ԧԧ", "ԦԦ", "ԧԧ", "ԧԧ", "ԧԧ", ],
+[ "ﬓﬔﬕﬖﬗ", "ﬓﬔﬕﬖﬗ", "ﬓﬔﬕﬖﬗ", "ﬓﬔﬕﬖﬗ", "ﬓﬔﬕﬖﬗ", "Մնﬔﬕﬖﬗ", "ՄՆՄԵՄԻՎՆՄԽ", "ﬓﬔﬕﬖﬗ", "մնմեմիվնմխ", "մնմեմիվնմխ", ],
+[ "ʼn groot", "ʼn groot", "ʼn Groot", "ʼn GROOT", "ʼn groot", "ʼN Groot", "ʼN GROOT", "ʼn groot", "ʼn groot", "ʼn groot", ],
+[ "ẚ", "ẚ", "ẚ", "ẚ", "ẚ", "Aʾ", "Aʾ", "ẚ", "aʾ", "aʾ", ],
+[ "ff", "ff", "ff", "ff", "ff", "Ff", "FF", "ff", "ff", "ff", ],
+[ "ǰ", "ǰ", "ǰ", "ǰ", "ǰ", "J̌", "J̌", "ǰ", "ǰ", "ǰ", ],
+[ "550 nm or Å", "550 nm or å", "550 Nm Or Å", "550 NM OR Å", "550 nm or å", "550 Nm Or Å", "550 NM OR Å", "550 nm or å", "550 nm or å", "550 nm or å", ],
+);
+
+ use feature qw(fc);
+
+ for (@test_table) {
+ my ($simple_lc, $simple_tc, $simple_uc, $simple_fc) = @{$_}[1, 2, 3, 7];
+ my ($orig, $lower, $titlecase, $upper, $fc_turkic, $fc_full) = @{$_}[0,4,5,6,8,9];
+
+ is( fc($orig), $fc_full, 'fc works' );
+ is( "\F$orig", $fc_full, '\F works' );
+ is( lc($orig), $lower, 'lc works' );
+ is( "\L$orig", $lower, '\L works' );
+ is( uc($orig), $upper, 'uc works' );
+ is( "\U$orig", $upper, '\U works' );
+ }
+}
+
+{
+ use feature qw(fc);
+ package Eeyup { use overload q{""} => sub { "\x{df}" }, fallback => 1 }
+ package Uunope { use overload q{""} => sub { "\x{30cb}" }, fallback => 1 }
+ package Undef { use overload q{""} => sub { undef }, fallback => 1 }
+
+ my $obj = bless {}, "Eeyup";
+ is(fc($obj), "ss", "fc() works on overloaded objects returning latin-1");
+ $obj = bless {}, "Eeyup";
+ is("\F$obj", "ss", '\F works on overloaded objects returning latin-1');
+
+ $obj = bless {}, "Uunope";
+ is(fc($obj), "\x{30cb}", "fc() works on overloaded objects returning UTF-8");
+ $obj = bless {}, "Uunope";
+ is("\F$obj", "\x{30cb}", '\F works on overloaded objects returning UTF-8');
+
+ $obj = bless {}, "Undef";
+ my $warnings;
+ {
+ no warnings;
+ use warnings "uninitialized";
+ local $SIG{__WARN__} = sub { $warnings++; like(shift, qr/Use of uninitialized value (?:\$obj )?in fc/) };
+ fc(undef);
+ fc($obj);
+ }
+ is( $warnings, 2, "correct number of warnings" );
+
+ my $fetched = 0;
+ package Derpy { sub TIESCALAR { bless {}, shift } sub FETCH { $fetched++; "\x{df}" } }
+
+ tie my $x, "Derpy";
+
+ is( fc($x), "ss", "fc() works on tied values" );
+ is( $fetched, 1, "and only calls the magic once" );
+
+}
+
+{
+ use feature qw( fc );
+ my $troublesome1 = "\xdf" x 11; #SvLEN should be 12, SvCUR should be 11
+ #So this should force fc() to grow the string.
+
+ is( fc($troublesome1), "ss" x 11, "fc() grows the string" );
+
+ my $troublesome2 = "abcdef:\x{df}:fjksjs"; #SvLEN should be 16, SvCUR should be 15
+ is( fc($troublesome2), "abcdef:ss:fjksjs", "fc() expands \\x{DF} in the middle of a string that needs to grow" );
+
+ my $troublesome3 = ":\x{df}:";
+ is( fc($troublesome3), ":ss:", "fc() expands \\x{DF} in the middle of a string" );
+
+
+ my $troublesome4 = "\x{B5}"; #\N{MICRON SIGN} is latin-1, but its foldcase is in UTF-8
+
+ is( fc($troublesome4), "\x{3BC}", "fc() for a latin-1 \x{B5} returns UTF-8" );
+ ok( !utf8::is_utf8($troublesome4), "fc() doesn't upgrade the original string" );
+
+
+ my $troublesome5 = "\x{C9}abda\x{B5}aaf\x{C8}"; # Up until foldcasing \x{B5}, the string
+ # was in Latin-1. This tests that the
+ # results don't have illegal UTF-8
+ # (i.e. leftover latin-1) in them
+
+ is( fc($troublesome5), "\x{E9}abda\x{3BC}aaf\x{E8}" );
+}
+
+{
+ use feature qw( fc unicode_strings );
+
+ # This tests both code paths in pp_fc
+
+ for (0..0xff) {
+ my $latin1 = chr;
+ my $utf8 = $latin1;
+ utf8::downgrade($latin1); #No-op, but doesn't hurt
+ utf8::upgrade($utf8);
+ is(fc($latin1), fc($utf8), "fc() gives the same results for \\x{$_} in Latin-1 and UTF-8 under unicode_strings");
+ {
+ use locale;
+ is(fc($latin1), lc($latin1), "use locale; fc(qq{\\x{$_}}), lc(qq{\\x{$_}}) when qq{\\x{$_}} is in latin-1");
+ is(fc($utf8), lc($utf8), "use locale; fc(qq{\\x{$_}}), lc(qq{\\x{$_}}) when qq{\\x{$_}} is in latin-1");
+ }
+ {
+ no feature 'unicode_strings';
+ is(fc($latin1), lc($latin1), "under nothing, fc() for <256 is the same as lc");
+ }
+ }
+}
+
my $num_tests = curr_test() - 1;
die qq[$0: failed to find casefoldings from "$CF"\n] unless $num_tests > 0;