forked from rurban/perl-compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathissue29.t
61 lines (55 loc) · 1.57 KB
/
issue29.t
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
49
50
51
52
53
54
55
56
57
58
59
60
61
#! /usr/bin/env perl
# http://code.google.com/p/perl-compiler/issues/detail?id=29
use strict;
BEGIN {
if ($] < 5.008) {
print "1..1\nok 1 #skip 5.6 has no IO discipline\n"; exit;
}
}
use Test::More tests => 2;
use Config;
my $DEBUGGING = ($Config{ccflags} =~ m/-DDEBUGGING/);
my $ITHREADS = ($Config{useithreads});
my $name = "ccode29i";
my $script = <<'EOF';
use open qw(:std :utf8);
$_ = <>;
print unpack('U*', $_), " ";
print $_ if /\w/;
EOF
open F, ">", "$name.pl";
print F $script;
close F;
#$ENV{LC_ALL} = 'C.UTF-8'; $ENV{LANGUAGE} = $ENV{LANG} = 'en';
my $expected = "24610 ö";
my $runperl = $^X =~ m/\s/ ? qq{"$^X" -Iblib/arch -Iblib/lib} : "$^X -Iblib/arch -Iblib/lib";
system "$runperl blib/script/perlcc -o $name $name.pl";
unless (-e $name or -e "$name.exe") {
print "ok 1 #skip perlcc failed. Try -Bdynamic or -Bstatic or fix your ldopts.\n";
print "ok 2 #skip\n";
exit;
}
my $runexe = $^O eq 'MSWin32' ? "$name.exe" : "./$name";
my $result = `echo "ö" | $runexe`;
$result =~ s/\n$//;
TODO: {
local $TODO = "B::C issue 29 utf8 perlio";
ok($result eq $expected, "'$result' ne '$expected'");
}
system "$runperl -MO=-qq,Bytecode,-o$name.plc $name.pl";
unless (-e "$name.plc") {
print "ok 2 #skip perlcc -B failed.\n";
exit;
}
$runexe = "$runperl -MByteLoader $name.plc";
$result = `echo "ö" | $runexe`;
$result =~ s/\n$//;
TODO: {
local $TODO = "B::Bytecode issue 29 utf8 perlio"
if $] >= 5.011004 and $ITHREADS;
ok($result eq $expected, "'$result' eq '$expected'");
}
END {
unlink($name, "$name.plc", "$name.pl", "$name.exe")
if $result eq $expected;
}