Commit | Line | Data |
6be7c101 |
1 | # $Id: enc_module.t,v 1.1 2003/02/28 01:40:27 dankogai Exp dankogai $ |
2 | # This file is in euc-jp |
3 | BEGIN { |
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 | } |
13 | if (ord("A") == 193) { |
14 | print "1..0 # encoding pragma does not support EBCDIC platforms\n"; |
15 | exit(0); |
16 | } |
17 | } |
18 | use lib 't'; |
19 | use lib qw(ext/Encode/t ../ext/Encode/t); # in case of perl core |
20 | use Mod_EUCJP; |
21 | use encoding "euc-jp"; |
22 | use Test::More tests => 3; |
23 | use File::Basename; |
24 | use File::Spec; |
25 | use File::Compare qw(compare_text); |
26 | |
27 | my $dir = dirname(__FILE__); |
28 | my $file0 = File::Spec->catfile($dir,"enc_module.enc"); |
29 | my $file1 = File::Spec->catfile($dir,"$$.enc"); |
30 | |
31 | my $obj = Mod_EUCJP->new; |
32 | # Isn't this dangerous in that we lose all possible warnings? |
33 | # Maybe a scoped use warnings 'something' instead? --jhi |
34 | local $SIG{__WARN__} = sub{}; # to silence reopening STD(IN|OUT) w/o closing |
35 | |
36 | open STDOUT, ">", $file1 or die "$file1:$!"; |
37 | print $obj->str, "\n"; |
38 | $obj->set("¥Æ¥¹¥Èʸ»úÎó"); |
39 | print $obj->str, "\n"; |
40 | close STDOUT; |
41 | |
42 | my $cmp = compare_text($file0, $file1); |
43 | is($cmp, 0, "encoding vs. STDOUT"); |
44 | unlink $file1 unless $cmp; |
45 | |
46 | my @cmp = qw/½é´üʸ»úÎó ¥Æ¥¹¥Èʸ»úÎó/; |
47 | open STDIN, "<", $file0 or die "$file0:$!"; |
48 | $obj = Mod_EUCJP->new; |
49 | my $i = 0; |
50 | while(<STDIN>){ |
51 | chomp; |
52 | is ($cmp[$i++], $_, "encoding vs. STDIN - $i"); |
53 | } |
54 | |
55 | __END__ |
56 | |