issue169.t 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 "test.pl";
  8. }
  9. use Test::More tests => 3;
  10. use B::C ();
  11. #my $todo = ($B::C::VERSION ge '1.46') ? "" : "TODO ";
  12. my $todo = "TODO ";
  13. ctestok(1,'C,-O3','ccode169i',<<'EOF',$todo.'Attribute::Handlers #169');
  14. package MyTest;
  15. use Attribute::Handlers;
  16. sub Check :ATTR {
  17. #print "called\n";
  18. print "o" if ref $_[4] eq 'ARRAY' && join(',', @{$_[4]}) eq join(',', qw/a b c/);
  19. }
  20. sub a_sub :Check(qw/a b c/) {
  21. return "k";
  22. }
  23. print a_sub()."\n";
  24. EOF
  25. ctestok(2,'C,-O3','ccode169i',<<'EOF',$todo.'run-time attributes::get #278');
  26. our $anon1;
  27. eval q/$anon1 = sub : method { $_[0]++ }/;
  28. use attributes;
  29. @attrs = eval q/attributes::get $anon1/;
  30. print qq{ok\n} if "@attrs" eq "method";
  31. #print "@attrs"
  32. EOF
  33. ctestok(3,'C,-O3','ccode169i',<<'EOF',($] >= 5.012 ? "" : "TODO 5.10 ").'compile-time attributes::get #278');
  34. use attributes;
  35. our $anon = sub : method { $_[0]++ };
  36. @attrs = attributes::get $anon;
  37. print qq{ok\n} if "@attrs" eq "method";
  38. EOF