forked from rurban/perl-compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathissue34.t
63 lines (57 loc) · 1.33 KB
/
issue34.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
62
63
#! /usr/bin/env perl
# http://code.google.com/p/perl-compiler/issues/detail?id=34
# B::C -O4 ignores $/ = undef
use Test::More tests => 2;
use strict;
my $base = "ccode34i";
sub test {
my ($num, $script, $expected, $todo) = @_;
my $name = $base."_$num";
unlink($name, "$name.c", "$name.pl", "$name.exe");
open F, ">", "$name.pl";
print F $script;
close F;
my $runperl = $^X =~ m/\s/ ? qq{"$^X"} : $^X;
$runperl .= " -Iblib/arch -Iblib/lib";
my $b = $] > 5.008 ? "-qq,CC" : "CC";
system "$runperl -MO=$b,-o$name.c $name.pl";
unless (-e "$name.c") {
print "not ok 1 #B::CC failed\n";
exit;
}
system "$runperl blib/script/cc_harness -q -o $name $name.c";
my $runexe = $^O eq 'MSWin32' ? "$name.exe" : "./$name";
ok(-e $runexe, "$runexe exists");
my $result = `$runexe`;
my $ok = $result eq $expected;
if ($todo) {
TODO: {
local $TODO = $todo;
ok($ok);
}
} else {
ok($ok);
}
if ($ok) {
unlink($runexe, "$name.c", "$name.pl", "$name.dat");
}
}
my $script = <<'EOF';
$/ = undef;
open FILE, 'ccode34i.dat';
my $first = <FILE>;
my $rest = <FILE>;
print "1:\n$first";
print "2:\n$rest";
EOF
open F, ">", "ccode34i.dat";
print F "line1\n";
print F "line2\n";
close F;
my $expected = <<'EOF1';
1:
line1
line2
2:
EOF1
test(1, $script, $expected, 'B::C,-O4 issue 34 $/=undef ignored');