Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
C: #231 fix -C $^UNICODE tests
support seperate ctest() backend options being passed to perl,
like "C,-O3 -CL" => "-CL" being passed to perl not the compiler
  • Loading branch information
Reini Urban committed Dec 5, 2013
1 parent 18c3cca commit 2ea7784
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/B/C.pm
Expand Up @@ -5101,7 +5101,7 @@ _EOT15
print sprintf(qq{ sv_setpv_mg(get_sv("^", GV_ADD|GV_NOTQUAL), %s);\n}, cstring($^)) if $^ ne "STDOUT_TOP";
print sprintf(qq{ sv_setpv_mg(get_sv("~", GV_ADD|GV_NOTQUAL), %s);\n}, cstring($~)) if $~ ne "STDOUT";
print qq{ sv_setiv_mg(get_sv("%", GV_ADD|GV_NOTQUAL), $%);\n} if $%; #PAGE_NUMBER
print qq{ sv_setiv_mg(get_sv("-", GV_ADD|GV_NOTQUAL), $-);\n} if $-; #LINES_LEFT
print qq{ sv_setiv_mg(get_sv("-", GV_ADD|GV_NOTQUAL), $-);\n} if !$- or $- != 60; #LINES_LEFT
print qq{ sv_setiv_mg(get_sv("=", GV_ADD|GV_NOTQUAL), $=);\n} if $= != 60; #LINES_PER_PAGE

# deprecated global vars
Expand Down
23 changes: 14 additions & 9 deletions t/issue256.t
Expand Up @@ -19,12 +19,12 @@ my $pv_vars = {';' => "\34",
my $iv_vars = {'^H' => 0,
'|' => 0,
'%' => 0,
'-' => 0,
'-' => 60,
'=' => 60,
#'{^UNICODE}' => 0,
#'{^UTF8LOCALE}' => 1
};
use Test::More tests => 2;
use Test::More tests => 4;

my $script = '';
$script .= sprintf('BEGIN{ $%s = "a"} $%s = "a"; print qq{not ok - \$%s = $%s\n} if $%s ne "a";'."\n",
Expand All @@ -39,10 +39,15 @@ ctestok(2,'C,-O3','ccode256i',
'BEGIN{$, = " "; } $, = " "; print $, eq " " ? "ok\n" : qq{not ok - \$, = $,\n}',
'#256 initialize $,');

# TODO: need -C switches to set the rest
#ctestok(3,'C,-O3','ccode256i',
# 'BEGIN{ ${^UNICODE} = 15; } ${^UNICODE} = 15; print qq{not ok - \${^UNICODE} = ${^UNICODE}\n} if ${^UNICODE} != 15;',
# '#256 initialize ${^UNICODE}');
#ctestok(4,'C,-O3','ccode256i',
# 'BEGIN{ ${^UTF8LOCALE} = 2; } ${^UTF8LOCALE} = 2; print ${^UTF8LOCALE} == 2 ? "ok\n" : qq{not ok - \${^UTF8LOCALE} = ${^UTF8LOCALE}\n};',
# '#256 initialize ${^UTF8LOCALE}');
# need -C -CL switches to set UNICODE
if ($] >= 5.010001) {
ctestok(3,'C,-O3 -C','ccode231i',
'print ${^UNICODE} ? "ok" : "not ok", " - \${^UNICODE} = ${^UNICODE}\n";',
'#231 initialize ${^UNICODE}');
ctestok(4,'C,-O3 -CL','ccode231i',
'print ${^UTF8LOCALE} == 1 ? "ok\n" : qq{not ok - \${^UTF8LOCALE} = ${^UTF8LOCALE}\n};',
'#231 initialize ${^UTF8LOCALE}');
} else {
print "ok 3 - skip -C with <5.10.1\n";
print "ok 4 - skip -CL with <5.10.1\n";
}
6 changes: 4 additions & 2 deletions t/test.pl
Expand Up @@ -706,9 +706,11 @@ sub ctest {
my $runperl = $^X =~ m/\s/ ? qq{"$^X"} : $^X;
# we don't want to change STDOUT/STDERR on STDOUT/STDERR tests, so no -qq
my $nostdoutclobber = $base !~ /^ccode93i/;
my $post = '';
my $b = ($] > 5.008 and $nostdoutclobber) ? "-qq,$backend" : "$backend";
$b .= q(,-fno-fold,-fno-warnings) if $] >= 5.013005;
system "$runperl ".Mblib." -MO=$b,-o$name.c $name.pl";
($b, $post) = split(" ", $b);
$b .= q(,-fno-fold,-fno-warnings) if $] >= 5.013005 and $b !~ /-O3/;
system "$runperl ".Mblib." -MO=$b,-o$name.c $post $name.pl";
unless (-e "$name.c") {
print "not ok $num #B::$backend failed\n";
exit;
Expand Down

0 comments on commit 2ea7784

Please sign in to comment.