issue36.t 803 B

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