summaryrefslogtreecommitdiff
path: root/t/comp/utf.t
blob: 904c8a378738c5dffc691a66fe669b4d28befb11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!./perl

BEGIN {
    chdir 't' if -d 't';
    @INC = '../lib';
    unless (find PerlIO::Layer 'perlio') {
	print "1..0 # Skip: not perlio\n";
	exit 0;
    }
    if ($ENV{PERL_CORE_MINITEST}) {
	print "1..0 # Skip: no dynamic loading on miniperl, no threads\n";
	exit 0;
    }
    require Config; import Config;
    if ($Config{'extensions'} !~ /\bEncode\b/) {
      print "1..0 # Skip: Encode was not built\n";
      exit 0;
    }
}

BEGIN { require "./test.pl"; }

plan(tests => 18);

my $BOM = chr(0xFEFF);

sub test {
    my ($enc, $tag, $bom) = @_;
    open(UTF_PL, ">:raw:encoding($enc)", "utf$$.pl")
	or die "utf.pl($enc,$tag,$bom): $!";
    print UTF_PL $BOM if $bom;
    print UTF_PL "$tag\n";
    close(UTF_PL);
    my $got = do "./utf$$.pl";
    is($got, $tag);
}

for my $bom (0, 1) {
    for my $enc (qw(utf16le utf16be utf8)) {
	for my $value (123, 1234, 12345) {
	    test($enc, $value, $bom);
	}
    }
}

END {
    1 while unlink "utf$$.pl";
}