#! /usr/bin/env perl
my
$ITHREADS
=
$Config
{useithreads};
my
$base
=
"ccode35i"
;
sub
test {
my
(
$num
,
$script
,
$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
$ok
= -e
$name
or -e
"$name.exe"
;
if
(
$todo
) {
TODO: {
local
$TODO
=
$todo
;
ok(
$ok
,
'CC same variable in different scope'
);
}
}
else
{
ok(
$ok
,
'CC same variable in different scope'
);
}
if
(
$ok
) {
unlink
(
$name
,
"$name.c"
,
"$name.pl"
,
"$name.exe"
);
}
}
my
$script
=
<<'EOF';
sub new {}
sub test {
{ my $x = 1; my $y = $x + 1;}
my $x = 2;
if ($x != 3) { 4; }
}
EOF
test(1,
$script
,
$B::CC::VERSION
< 1.08 ?
"B::CC issue 35"
:
undef
);
$script
=
<<'EOF';
sub test {
my $tmp5 = 1;
my $x = $tmp5 + 1;
if ($x != 3) { 4; }
}
EOF
test(2,
$script
, (
$B::CC::VERSION
< 1.08 and
$ITHREADS
) ?
"B::CC issue 35 fail3.pl"
:
undef
);