14 my $file="../lib/unicore/CaseFolding.txt";
15 open my $fh,"<",$file or die "Failed to read '$file': $!";
18 my ($line,$comment)= split/\s+#\s+/, $_;
19 my ($cp,$type,@folded)=split/[\s;]+/,$line||'';
20 next unless $type and ($type eq 'F' or $type eq 'C');
21 my $fold_above_latin1 = grep { hex("0x$_") > 255 } @folded;
22 $_="\\x{$_}" for @folded;
26 foreach my $swap (0, 1) { # swap lhs and rhs, or not.
27 foreach my $charclass (0, 1) { # Put rhs in [...], or not
31 $lhs = join "", @folded;
33 $rhs = "[$rhs]" if $charclass;
37 foreach my $rhs_char (@folded) {
38 $rhs .= '[' if $charclass;
40 $rhs .= ']' if $charclass;
46 # Try both Latin1 and Unicode for code points below 256
47 foreach my $upgrade ("", 'utf8::upgrade($c); ') {
49 next if $swap && $fold_above_latin1;
50 next if !$swap && $cpv > 255;
52 my $eval = "my \$c = $lhs; $upgrade\$c =~ $rhs";
53 #print __LINE__, ": $eval\n";
54 push @tests, qq[ok(eval '$eval', '$eval - $comment')];
55 if (! $swap && ($cp eq '0390' || $cp eq '03B0')) {
56 $tests[-1]="TODO: { local \$::TODO='[13:41] <BinGOs> cue *It is all Greek to me* joke.';\n$tests[-1] }"
57 } elsif ($charclass && @folded > 1 && $swap && ! $upgrade && ! $fold_above_latin1) {
58 $tests[-1]="TODO: { local \$::TODO='Multi-char, non-utf8 folded inside character class [ ] doesnt work';\n$tests[-1] }"
59 } elsif (! $upgrade && $cpv >= 128 && $cpv <= 255 && $cpv != 0xb5) {
60 $tests[-1]="TODO: { local \$::TODO='Most non-utf8 latin1 doesnt work';\n$tests[-1] }"
61 } elsif (! $swap && $charclass && @folded > 1) {
62 # There are a few of these that pass; most fail.
63 $tests[-1]="TODO: { local \$::TODO='Some multi-char, f8 folded inside character class [ ] doesnt work';\n$tests[-1] }"
70 eval join ";\n","plan tests=>".($count-1),@tests,"1"