issue169.t 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #! /usr/bin/env perl
  2. # http://code.google.com/p/perl-compiler/issues/detail?id=169
  3. # Attribute::Handlers
  4. use strict;
  5. BEGIN {
  6. unshift @INC, 't';
  7. require TestBC;
  8. }
  9. use Test::More tests => 3;
  10. use Config;
  11. use B::C ();
  12. my $CPERL = $Config{usecperl};
  13. #my $todo = ($B::C::VERSION ge '1.46') ? "" : "TODO ";
  14. my $todo = "TODO ";
  15. ctestok(1,'C,-O3','ccode169i',<<'EOF',$todo.'Attribute::Handlers #169');
  16. package MyTest;
  17. use Attribute::Handlers;
  18. sub Check :ATTR {
  19. #print "called\n";
  20. print "o" if ref $_[4] eq 'ARRAY' && join(',', @{$_[4]}) eq join(',', qw/a b c/);
  21. }
  22. sub a_sub :Check(qw/a b c/) {
  23. return "k";
  24. }
  25. print a_sub()."\n";
  26. EOF
  27. $todo = "" if $] > 5.021006;
  28. $todo = "TODO 5.26 " if $] > 5.025003;
  29. ctestok(2,'C,-O3','ccode169i',<<'EOF',$todo.'run-time attributes::get #278');
  30. our $anon1;
  31. eval q/$anon1 = sub : method { $_[0]++ }/;
  32. use attributes;
  33. @attrs = eval q/attributes::get $anon1/;
  34. print qq{ok\n} if "@attrs" eq "method";
  35. #print "@attrs"
  36. EOF
  37. $todo = "TODO 5.10 " if $] < 5.012;
  38. $todo = "TODO 5.25 " if $] > 5.025 and !$CPERL;
  39. ctestok(3,'C,-O3','ccode169i',<<'EOF',$todo.'compile-time attributes::get #278');
  40. use attributes;
  41. our $anon = sub : method { $_[0]++ };
  42. @attrs = attributes::get $anon;
  43. print qq{ok\n} if "@attrs" eq "method";
  44. EOF