forked from rurban/perl-compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathissue54.t
46 lines (41 loc) · 1.03 KB
/
issue54.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
#! /usr/bin/env perl
# http://code.google.com/p/perl-compiler/issues/detail?id=54
# pad_swipe error with package pmcs
use strict;
my $name = "ccode54p";
use Test::More tests => 1;
my $pkg = <<"EOF";
package $name;
sub test {
\$abc='ok';
print "\$abc\\n";
}
1;
EOF
open F, ">", "$name.pm";
print F $pkg;
close F;
my $expected = "ok";
my $runperl = $^X =~ m/\s/ ? qq{"$^X"} : $^X;
my $Mblib = "-Iblib/arch -Iblib/lib";
if ($] < 5.008) {
system "$runperl -MO=Bytecode,-o$name.pmc $name.pm";
} else {
system "$runperl $Mblib -MO=-qq,Bytecode,-H,-o$name.pmc $name.pm";
}
unless (-e "$name.pmc") {
print "not ok 1 #B::Bytecode failed.\n";
exit;
}
my $runexe = "$runperl $Mblib -I. -M$name -e\"$name\::test\"";
$runexe = "$runperl -MByteLoader -I. -M$name -e\"$name\::test\"" if $] < 5.008;
my $result = `$runexe`;
$result =~ s/\n$//;
SKIP: {
skip "no pmc on 5.6 (yet)", 1 if $] < 5.008;
ok($result eq $expected, "issue54 - pad_swipe error with package pmcs");
}
END {
unlink($name, "$name.pmc", "$name.pm")
if $result eq $expected;
}