issue208.t 1.1 KB

123456789101112131415161718192021222324252627282930
  1. #! /usr/bin/env perl
  2. # http://code.google.com/p/perl-compiler/issues/detail?id=208
  3. # missing DESTROY call at DESTRUCT time
  4. use strict;
  5. BEGIN {
  6. unshift @INC, 't';
  7. require "test.pl";
  8. }
  9. use Test::More tests => 2;
  10. my $script = <<'EOF';
  11. sub MyKooh::DESTROY { print "${^GLOBAL_PHASE} MyKooh " } my $k=bless {}, MyKooh;
  12. sub OurKooh::DESTROY { print "${^GLOBAL_PHASE} OurKooh" } our $k=bless {}, OurKooh;
  13. EOF
  14. my $expected = ($] >= 5.014 ? 'RUN MyKooh DESTRUCT OurKooh' : ' MyKooh OurKooh');
  15. # fixed with 1.42_66, 5.16+5.18
  16. # for older perls and -O3 fixed with 1.45_02
  17. use B::C ();
  18. my $todo = ($] > 5.015 and $B::C::VERSION gt '1.42_65') ? "" : "TODO ";
  19. if ($] < 5.015) {
  20. $todo = ($B::C::VERSION gt '1.45_01') ? "" : "TODO ";
  21. }
  22. my $todo_o3 = ($] < 5.013 and $B::C::VERSION gt '1.45_01') ? "" : "TODO ";
  23. #if ($B::C::VERSION gt '1.45_03') { #broken with 1c5062f53 which enabled -ffast-destruct on -O0
  24. # $todo = $todo_o3 = $] > 5.013 ? "TODO " : "";
  25. #}
  26. ctest(1, $expected,'C','ccode208i',$script,$todo.'#208 missing DESTROY call at DESTRUCT time');
  27. ctest(2, $expected,'C,-O3','ccode208i',$script,$todo_o3.'#208 -ffast-destruct');