cc_last.t 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #! /usr/bin/env perl
  2. # B::CC limitations with last/next/continue. See README.
  3. # See also issue36.t
  4. use Test::More tests => 4;
  5. use strict;
  6. BEGIN {
  7. unshift @INC, 't';
  8. require "test.pl";
  9. }
  10. my $base = "ccode_last";
  11. # XXX Bogus. This is not the real 'last' failure as described in the README
  12. my $script1 = <<'EOF';
  13. # last outside loop
  14. label: {
  15. print "ok\n";
  16. my $i = 1;
  17. {
  18. last label if $i;
  19. }
  20. print " not ok\n";
  21. }
  22. EOF
  23. use B::CC;
  24. # 5.12 still fails test 1
  25. ctestok(1, "CC", $base, $script1,
  26. ($B::CC::VERSION < 1.08 or $] =~ m/5\.01[12]/
  27. ? "TODO last outside loop fixed with B-CC-1.08"
  28. : "last outside loop"));
  29. # computed labels are invalid
  30. my $script2 = <<'EOF';
  31. # Label not found at compile-time for last
  32. lab1: {
  33. print "ok\n";
  34. my $label = "lab1";
  35. last $label;
  36. print " not ok\n";
  37. }
  38. EOF
  39. #TODO: {
  40. #local $TODO = "Same result and errcode as uncompiled. Label not found for last";
  41. ctest(2, '$ok$', "CC", $base, $script2, "Label not found at compile-time for last");
  42. #}
  43. # Fixed by Heinz Knutzen for issue 36
  44. my $script3 = <<'EOF';
  45. # last for non-loop block
  46. {
  47. print "ok";
  48. last;
  49. print " not ok\n";
  50. }
  51. EOF
  52. ctestok(3, "CC", $base, $script3,
  53. $B::CC::VERSION < 1.08
  54. ? "TODO last for non-loop block fixed with B-CC-1.08"
  55. : "last for non-loop block");
  56. my $script4 = <<'EOF';
  57. # issue 55 segfault for non local loop exit
  58. LOOP:
  59. {
  60. my $sub = sub { last LOOP; };
  61. $sub->();
  62. }
  63. print "ok";
  64. EOF
  65. # TODO
  66. ctestok(4, "CC", $base, $script4,
  67. $B::CC::VERSION < 1.11
  68. ? "TODO B::CC issue 55 non-local exit with last => segv"
  69. : "non local loop exit");