issue98.t 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. use Config;
  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. open F, ">", "$name.pl";
  22. print F $source;
  23. close F;
  24. my $expected = "ok";
  25. my $runperl = $^X =~ m/\s/ ? qq{"$^X"} : $^X;
  26. my $Mblib = "-Iblib/arch -Iblib/lib";
  27. if ($] < 5.008) {
  28. system "$runperl -MO=Bytecode,-o$name.plc $name.pl";
  29. } else {
  30. system "$runperl $Mblib -MO=-qq,Bytecode,-H,-o$name.plc $name.pl";
  31. }
  32. unless (-e "$name.plc") {
  33. print "not ok 1 #B::Bytecode failed.\n";
  34. exit;
  35. }
  36. my $runexe = $] < 5.008
  37. ? "$runperl -MByteLoader $name.plc"
  38. : "$runperl $Mblib $name.plc";
  39. my $result = `$runexe`;
  40. $result =~ s/\n$//;
  41. SKIP: {
  42. skip "no features on 5.6", 1 if $] < 5.008;
  43. TODO: {
  44. local $TODO = "5.18thr bytecode" if $] >= 5.018 and $] < 5.019005 and $Config{useithreads};
  45. ok($result eq $expected, "issue98 - set feature hash");
  46. }
  47. }
  48. END {
  49. unlink($name, "$name.plc", "$name.pl")
  50. if $result eq $expected;
  51. }