This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Test that entries in %^H are actually independant.
[perl5.git] / t / comp / utf.t
CommitLineData
7aa207d6
JH
1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6 unless (find PerlIO::Layer 'perlio') {
7 print "1..0 # Skip: not perlio\n";
8 exit 0;
9 }
ec721aa4
NC
10 if ($ENV{PERL_CORE_MINITEST}) {
11 print "1..0 # Skip: no dynamic loading on miniperl, no threads\n";
12 exit 0;
13 }
d70c8551
MHM
14 require Config; import Config;
15 if ($Config{'extensions'} !~ /\bEncode\b/) {
16 print "1..0 # Skip: Encode was not built\n";
17 exit 0;
18 }
7aa207d6
JH
19}
20
21require "./test.pl";
22
23plan(tests => 15);
24
25my $BOM = chr(0xFEFF);
26
27sub test {
28 my ($enc, $tag, $bom) = @_;
ed45ef62 29 open(UTF_PL, ">:raw:encoding($enc)", "utf.pl")
7aa207d6
JH
30 or die "utf.pl($enc,$tag,$bom): $!";
31 print UTF_PL $BOM if $bom;
32 print UTF_PL "$tag\n";
33 close(UTF_PL);
34 my $got = do "./utf.pl";
35 is($got, $tag);
36}
37
38test("utf16le", 123, 1);
39test("utf16le", 1234, 1);
40test("utf16le", 12345, 1);
41test("utf16be", 123, 1);
42test("utf16be", 1234, 1);
43test("utf16be", 12345, 1);
44test("utf8", 123, 1);
45test("utf8", 1234, 1);
46test("utf8", 12345, 1);
47
48test("utf16le", 123, 0);
49test("utf16le", 1234, 0);
50test("utf16le", 12345, 0);
51test("utf16be", 123, 0);
52test("utf16be", 1234, 0);
53test("utf16be", 12345, 0);
54
55END {
56 1 while unlink "utf.pl";
57}