issue36.t 1007 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #! /usr/bin/env perl
  2. # http://code.google.com/p/perl-compiler/issues/detail?id=36
  3. # B::CC fails on some loops
  4. # The problem seems to be non deterministic.
  5. # Some runs of B::CC succeed, some fail and others give a warning.
  6. use B::CC;
  7. use Test::More tests => $B::CC::VERSION < 1.08 ? 5 : 1;
  8. use strict;
  9. BEGIN {
  10. unshift @INC, 't';
  11. require "test.pl";
  12. }
  13. # panic: leaveloop, no cxstack at /usr/local/lib/perl/5.10.1/B/CC.pm line 1977
  14. my $script = <<'EOF';
  15. sub f { shift == 2 }
  16. sub test {
  17. while (1) {
  18. last if f(2);
  19. }
  20. while (1) {
  21. last if f(2);
  22. }
  23. }
  24. EOF
  25. use B::CC;
  26. # The problem seems to be non deterministic.
  27. # Some runs of B::CC succeed, some fail and others give a warning.
  28. if ($B::CC::VERSION < 1.08) {
  29. ccompileok($_, "CC", "ccode36i", $script,
  30. "TODO B::CC issue 36 fixed with B-C-1.28 r556 (B::CC 1.08) by Heinz Knutzen")
  31. for 1..5;
  32. } else {
  33. ccompileok($_, "CC", "ccode36i", $script,
  34. "CC fails sometimes on some loops (fixed with B-C-1.28 r556)");
  35. }