fix CJKT.t failures on windows due to incorrect binmode()
[p5sagit/p5-mst-13.2.git] / ext / Encode / t / enc_module.t
CommitLineData
0f29a567 1# $Id: enc_module.t,v 1.3 2003/03/09 20:07:37 dankogai Exp dankogai $
6be7c101 2# This file is in euc-jp
3BEGIN {
4 require Config; import Config;
5 if ($Config{'extensions'} !~ /\bEncode\b/) {
6 print "1..0 # Skip: Encode was not built\n";
7 exit 0;
8 }
9 unless (find PerlIO::Layer 'perlio') {
10 print "1..0 # Skip: PerlIO was not built\n";
11 exit 0;
12 }
05ef2f67 13 if (defined ${^UNICODE} and ${^UNICODE} != 0){
14 print "1..0 # Skip: \${^UNICODE} == ${^UNICODE}\n";
15 exit 0;
16 }
6be7c101 17 if (ord("A") == 193) {
18 print "1..0 # encoding pragma does not support EBCDIC platforms\n";
19 exit(0);
20 }
21}
0f29a567 22use lib qw(t ext/Encode/t ../ext/Encode/t); # latter 2 for perl core
6be7c101 23use Mod_EUCJP;
24use encoding "euc-jp";
25use Test::More tests => 3;
26use File::Basename;
27use File::Spec;
28use File::Compare qw(compare_text);
29
30my $dir = dirname(__FILE__);
31my $file0 = File::Spec->catfile($dir,"enc_module.enc");
32my $file1 = File::Spec->catfile($dir,"$$.enc");
33
34my $obj = Mod_EUCJP->new;
6be7c101 35local $SIG{__WARN__} = sub{}; # to silence reopening STD(IN|OUT) w/o closing
36
37open STDOUT, ">", $file1 or die "$file1:$!";
38print $obj->str, "\n";
39$obj->set("¥Æ¥¹¥Èʸ»úÎó");
40print $obj->str, "\n";
41close STDOUT;
42
43my $cmp = compare_text($file0, $file1);
44is($cmp, 0, "encoding vs. STDOUT");
45unlink $file1 unless $cmp;
46
47my @cmp = qw/½é´üʸ»úÎó ¥Æ¥¹¥Èʸ»úÎó/;
48open STDIN, "<", $file0 or die "$file0:$!";
49$obj = Mod_EUCJP->new;
50my $i = 0;
51while(<STDIN>){
52 chomp;
53 is ($cmp[$i++], $_, "encoding vs. STDIN - $i");
54}
55
56__END__
57