Run vms/vms_yfix.pl, should have done that after changing
[p5sagit/p5-mst-13.2.git] / t / lib / encode.t
CommitLineData
656753f8 1BEGIN {
2 chdir 't' if -d 't';
3 @INC = '../lib';
5a814814 4 require Config; import Config;
5 if ($Config{'extensions'} !~ /\Encode\b/) {
6 print "1..0 # Skip: Encode was not built\n";
7 exit 0;
8 }
656753f8 9}
10use Test;
11use Encode qw(from_to);
12use charnames qw(greek);
13my @encodings = grep(/iso8859/,Encode::encodings());
14my $n = 2;
15plan test => 13+$n*@encodings;
16my $str = join('',map(chr($_),0x20..0x7E));
17my $cpy = $str;
18ok(length($str),from_to($cpy,'iso8859-1','Unicode'),"Length Wrong");
19ok($cpy,$str,"ASCII mangled by translating from iso8859-1 to Unicode");
20$cpy = $str;
21ok(from_to($cpy,'Unicode','iso8859-1'),length($str),"Length wrong");
22ok($cpy,$str,"ASCII mangled by translating from Unicode to iso8859-1");
23
24$str = join('',map(chr($_),0xa0..0xff));
87714904 25$cpy = $str;
656753f8 26ok(length($str),from_to($cpy,'iso8859-1','Unicode'),"Length Wrong");
27
28my $sym = Encode->getEncoding('symbol');
29my $uni = $sym->toUnicode('a');
30ok("\N{alpha}",substr($uni,0,1),"alpha does not map so symbol 'a'");
31$str = $sym->fromUnicode("\N{Beta}");
32ok("B",substr($str,0,1),"Symbol 'B' does not map to Beta");
33
34foreach my $enc (qw(symbol dingbats ascii),@encodings)
35 {
36 my $tab = Encode->getEncoding($enc);
37 ok(1,defined($tab),"Could not load $enc");
38 $str = join('',map(chr($_),0x20..0x7E));
39 $uni = $tab->toUnicode($str);
40 $cpy = $tab->fromUnicode($uni);
41 ok($cpy,$str,"$enc mangled translating to Unicode and back");
42 }
43