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 43 44 45 46 47 48
|
#!/usr/local/bin/perl
use strict;
use Benchmark;
use blib;
$| = 1;
my %code2str;
my @enc = qw/euc sjis jis utf8/;
for my $enc (@enc){
my $file = "t/table.$enc";
open F, $file or die "$file:$!";
binmode F;
read F, $code2str{$enc}, -s $file;
close F;
}
use Jcode;
use Unicode::Japanese;
my $tests;
for my $f (@enc){
for my $t (@enc){
$f eq $t and next;
$tests->{"$f->$t"} =
sub {
no strict 'refs';
Jcode->new($code2str{$f}, $f)->$t eq $code2str{$t}
or die;
};
}
}
timethese(0,
$tests);
__END__
my %tests;
for my $mod (qw/Jcode Unicode::Japanese/){
eval qq{ require $mod };
$@ and next;
"$mod loaded.";
no strict 'refs';
$tests{$mod} = sub {
}
}
|