Replace longhand invocations of test() with 3 nested loops.
[p5sagit/p5-mst-13.2.git] / t / comp / utf.t
1 #!./perl
2
3 BEGIN {
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     }
10     if ($ENV{PERL_CORE_MINITEST}) {
11         print "1..0 # Skip: no dynamic loading on miniperl, no threads\n";
12         exit 0;
13     }
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     }
19 }
20
21 BEGIN { require "./test.pl"; }
22
23 plan(tests => 18);
24
25 my $BOM = chr(0xFEFF);
26
27 sub test {
28     my ($enc, $tag, $bom) = @_;
29     open(UTF_PL, ">:raw:encoding($enc)", "utf$$.pl")
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
38 for my $bom (0, 1) {
39     for my $enc (qw(utf16le utf16be utf8)) {
40         for my $value (123, 1234, 12345) {
41             test($enc, $value, $bom);
42         }
43     }
44 }
45
46 END {
47     1 while unlink "utf$$.pl";
48 }