File: reg_fold.t

package info (click to toggle)
perl 5.10.1-17squeeze6
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 74,280 kB
  • ctags: 49,087
  • sloc: perl: 319,380; ansic: 193,238; sh: 37,981; pascal: 8,830; lisp: 7,515; cpp: 3,893; makefile: 2,375; xml: 1,972; yacc: 1,555
file content (42 lines) | stat: -rwxr-xr-x 1,112 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!perl

BEGIN {
    chdir 't' if -d 't';
    @INC = '../lib';
}

use strict;
use warnings;
use Test::More;
my $count=1;
my @tests;

my $file="../lib/unicore/CaseFolding.txt";
open my $fh,"<",$file or die "Failed to read '$file': $!";
while (<$fh>) {
    chomp;
    my ($line,$comment)= split/\s+#\s+/, $_;
    my ($cp,$type,@fc)=split/[\s;]+/,$line||'';
    next unless $type and ($type eq 'F' or $type eq 'C');
    $_="\\x{$_}" for @fc;
    my $cpv=hex("0x$cp");
    my $chr="chr(0x$cp)";
    my @str;
    push @str,$chr if $cpv<128 or $cpv>256;
    if ($cpv<256) {
        push @str,"do{my \$c=$chr; utf8::upgrade(\$c); \$c}"
    }

    foreach my $str ( @str ) {
        my $expr="$str=~/@fc/ix";
        my $t=($cpv > 256 || $str=~/^do/) ? "unicode" : "latin";
        push @tests,
            qq[ok($expr,'$chr=~/@fc/ix - $comment ($t string)')];
        $tests[-1]="TODO: { local \$TODO='[13:41] <BinGOs> cue *It is all Greek to me* joke.';\n$tests[-1] }"
            if $cp eq '0390' or $cp eq '03B0';
        $count++;
    }
}
eval join ";\n","plan tests=>".($count-1),@tests,"1"
    or die $@;
__DATA__