issue251.t 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #! /usr/bin/env perl
  2. # http://code.google.com/p/perl-compiler/issues/detail?id=251
  3. # empty cvs, exists and defined &cv
  4. use strict;
  5. BEGIN {
  6. unshift @INC, 't';
  7. require TestBC;
  8. }
  9. use Test::More tests => 7;
  10. use Config;
  11. my $name = 'ccode251i';
  12. use B::C ();
  13. my $todo = ($B::C::VERSION ge '1.43_06') ? "" : "TODO ";
  14. ctestok(1,'C,-O3',$name,<<'EOF', $todo.'#251 simple predeclaration');
  15. sub f;$e=exists &f;$d=defined &f;print "ok" if "-$e-$d-" eq "-1--";
  16. EOF
  17. ctestok(2,'C,-O3',$name,<<'EOF', ($] >= 5.018 ? "TODO 5.18 " : "").$todo.'#251 lvalue predeclaration');
  18. sub f :lvalue;$e=exists &f;$d=defined &f;print "ok" if "-$e-$d-" eq "-1--";
  19. EOF
  20. ctestok(3,'C,-O3',$name,<<'EOF', $todo.'#251 empty proto predeclaration');
  21. sub f ();$e=exists &f;$d=defined &f;print "ok" if "-$e-$d-" eq "-1--";
  22. EOF
  23. ctestok(4,'C,-O3',$name,<<'EOF', $todo.'#251 proto predeclaration');
  24. sub f ($);$e=exists &f;$d=defined &f;print "ok" if "-$e-$d-" eq "-1--";
  25. EOF
  26. ctestok(5,'C,-O3',$name,<<'EOF', '#251 regular cv definition');
  27. sub f{1};$e=exists &f;$d=defined &f;print "ok" if "-$e-$d-" eq "-1-1-";
  28. EOF
  29. # similar but not same as test 1
  30. # passes now threaded >= 5.8.9
  31. my $todo6 = ($] < 5.008009 or !$Config{useithreads}) ? "TODO " : "";
  32. ctestok(6,'C,-O3','ccode290i',<<'EOF', $todo6.'#290 empty sub exists && not defined');
  33. sub f; print "ok" if exists &f && not defined &f;
  34. EOF
  35. # and this works ok
  36. ctestok(7,'C,-O3','ccode290i',<<'EOF', '#290 empty sub not defined && exists');
  37. sub f; print "ok" if not defined &f && exists &f;
  38. EOF