Remove the "hack" that removes SVt_UTF8 in the UTF16 filter, by fixing t/TEST
[p5sagit/p5-mst-13.2.git] / t / comp / utf.t
CommitLineData
61ad1ccd 1#!./perl -w
7aa207d6 2
61ad1ccd 3print "1..18\n";
4my $test = 0;
7aa207d6 5
5c7da53c 6my %templates = (
7 utf8 => 'C0U',
8 utf16be => 'n',
9 utf16le => 'v',
10 );
11
12sub bytes_to_utf {
13 my ($enc, $content, $do_bom) = @_;
14 my $template = $templates{$enc};
15 die "Unsupported encoding $enc" unless $template;
16 return pack "$template*", ($do_bom ? 0xFEFF : ()), unpack "C*", $content;
17}
7aa207d6 18
19sub test {
20 my ($enc, $tag, $bom) = @_;
5c7da53c 21 open my $fh, ">", "utf$$.pl" or die "utf.pl: $!";
22 binmode $fh;
23 print $fh bytes_to_utf($enc, "$tag\n", $bom);
24 close $fh or die $!;
2d90ac95 25 my $got = do "./utf$$.pl";
61ad1ccd 26 $test = $test + 1;
27 if (!defined $got) {
28 print "not ok $test # $enc $tag $bom; got undef\n";
29 } elsif ($got ne $tag) {
30 print "not ok $test # $enc $tag $bom; got '$got'\n";
31 } else {
32 print "ok $test\n";
33 }
7aa207d6 34}
35
386ac4df 36for my $bom (0, 1) {
37 for my $enc (qw(utf16le utf16be utf8)) {
38 for my $value (123, 1234, 12345) {
39 test($enc, $value, $bom);
40 }
41 }
42}
7aa207d6 43
44END {
2d90ac95 45 1 while unlink "utf$$.pl";
7aa207d6 46}