My favorites | Sign in
Project Home Wiki Issues Source
Repository:
Checkout   Browse   Changes   Clones  
Changes to /t/issue98.t
000000000000 vs. 1addd054a73b Compare: vs.  Format:
Revision 1addd054a73b
Go to: 
Project members, sign in to write a code review
/t/issue98.t /t/issue98.t   1addd054a73b
  1 #! /usr/bin/env perl
  2 # http://code.google.com/p/perl-compiler/issues/detail?id=98
  3 # v5.15 Bytecode Attempt to access disallowed key 'strict/subs' in a restricted hash
  4 use strict;
  5 my $name = "ccode98i";
  6 use Test::More tests => 1;
  7
  8 # New bug reported by Zloysystem
  9 # This is common-sense.pm
  10 my $source = 'BEGIN {
  11 local $^W; # work around perl 5.16 spewing out warnings for next statement
  12 # use warnings
  13 ${^WARNING_BITS} ^= ${^WARNING_BITS} ^ "";
  14 # use strict, use utf8; use feature;
  15 $^H |= 0x1c820ec0;
  16 @^H{qw(feature___SUB__ feature_fc feature_unicode feature_evalbytes feature_say feature_state feature_switch)} = (1) x 7;}
  17 sub test { eval(""); }
  18 print q(ok);';
  19 # old bug reported by Zloysystem
  20 #$source = "use strict; eval(\@_);print q(ok);";
  21
  22 open F, ">", "$name.pl";
  23 print F $source;
  24 close F;
  25
  26 my $expected = "ok";
  27 my $runperl = $^X =~ m/\s/ ? qq{"$^X"} : $^X;
  28 my $Mblib = "-Iblib/arch -Iblib/lib";
  29 if ($] < 5.008) {
  30 system "$runperl -MO=Bytecode,-o$name.plc $name.pl";
  31 } else {
  32 system "$runperl $Mblib -MO=-qq,Bytecode,-H,-o$name.plc $name.pl";
  33 }
  34 unless (-e "$name.plc") {
  35 print "not ok 1 #B::Bytecode failed.\n";
  36 exit;
  37 }
  38 my $runexe = $] < 5.008
  39 ? "$runperl -MByteLoader $name.plc"
  40 : "$runperl $Mblib $name.plc";
  41 my $result = `$runexe`;
  42 $result =~ s/\n$//;
  43
  44 SKIP: {
  45 skip "no features on 5.6", 1 if $] < 5.008;
  46 ok($result eq $expected, "issue98 - set feature hash");
  47 }
  48
  49 END {
  50 unlink($name, "$name.plc", "$name.pl")
  51 if $result eq $expected;
  52 }
Powered by Google Project Hosting