left-over "use 5.7.2" in threads.pm
[p5sagit/p5-mst-13.2.git] / ext / Encode / t / jperl.t
CommitLineData
3ef515df 1#
2# $Id: jperl.t,v 1.11 2002/03/31 22:12:13 dankogai Exp dankogai $
3#
4# This script is written in euc-jp
5
6use strict;
7use Test::More tests => 15;
8my $Debug = shift;
9
10no encoding; # ensure
11my $Enamae = "\xbe\xae\xbb\xf4\x20\xc3\xc6"; # euc-jp, with \x escapes
12use encoding "euc-jp";
13
14my $Namae = "¾®»ô ÃÆ"; # in Japanese, in euc-jp
15my $Name = "Dan Kogai"; # in English
16# euc-jp in \x format but after the pragma. But this one will be converted!
17my $Ynamae = "\xbe\xae\xbb\xf4\x20\xc3\xc6";
18
19
20my $str = $Namae; $str =~ s/¾®»ô ÃÆ/Dan Kogai/o;
21is($str, $Name, q{regex});
22$str = $Namae; $str =~ s/$Namae/Dan Kogai/o;
23is($str, $Name, q{regex - with variable});
24is(length($Namae), 4, q{utf8:length});
25{
26 use bytes;
27 # converted to UTF-8 so 3*3+1
28 is(length($Namae), 10, q{bytes:length});
29 #
30 is(length($Enamae), 7, q{euc:length}); # 2*3+1
31 is ($Namae, $Ynamae, q{literal conversions});
32 isnt($Enamae, $Ynamae, q{before and after});
33 is($Enamae, Encode::encode('euc-jp', $Namae));
34}
35# let's test the scope as well. Must be in utf8 realm
36is(length($Namae), 4, q{utf8:length});
37
38{
39 no encoding;
40 ok(! defined(${^ENCODING}), q{no encoding;});
41}
42# should've been isnt() but no scoping is suported -- yet
43ok(! defined(${^ENCODING}), q{not scoped yet});
44{
45 # now let's try some real black magic!
46 local(${^ENCODING}) = Encode::find_encoding("euc-jp");
47 my $str = "\xbe\xae\xbb\xf4\x20\xc3\xc6";
48 is (length($str), 4, q{black magic:length});
49 is ($str, $Enamae, q{black magic:eq});
50}
51ok(! defined(${^ENCODING}), q{out of black magic});
52use bytes;
53is (length($Namae), 10);
541;
55__END__
56
57