1 # Before `make install' is performed this script should be runnable with
2 # `make test'. After `make install' it should work as `perl test.pl'
4 ######################### We start with some black magic to print on failure.
11 # Change 1..1 below to 1..last_test_to_print .
12 # (It may become useful if the test is moved to ./t subdirectory.)
14 END {print "not ok 1\n" unless $loaded;}
16 use Attribute::Handlers;
19 ######################### End of black magic.
21 # Insert your test code below (better if it prints "ok 13"
22 # (correspondingly "not ok 13") depending on the success of chunk 13
25 sub ok { $::count++; push @::results, [$_[1], $_[0]?"":"not "]; }
27 END { print "1..$::count\n";
28 print map "$_->[1]ok $_->[0]\n", sort {$a->[0]<=>$b->[0]} @::results }
32 no warnings 'redefine';
34 sub UNIVERSAL::Okay :ATTR { ::ok @{$_[4]} }
36 sub Dokay :ATTR(SCALAR) { ::ok @{$_[4]} }
37 sub Dokay :ATTR(HASH) { ::ok @{$_[4]} }
38 sub Dokay :ATTR(ARRAY) { ::ok @{$_[4]} }
39 sub Dokay :ATTR(CODE) { ::ok @{$_[4]} }
41 sub Vokay :ATTR(VAR) { ::ok @{$_[4]} }
43 sub Aokay :ATTR(ANY) { ::ok @{$_[4]} }
53 my Test $x2 :Dokay(1,5);
57 my Test $x4 :Dokay(1,7);
68 # BEGIN {eval 'sub y2 :Vokay(0,16) {}; 1' or
75 sub z :Aokay(1,20) {};
82 my Test $x6 :Dokay(1,22);
92 BEGIN { eval 'my $x7 :Dokay(0,28)' or ::ok(1,28); }
93 my Test $x8 :Dokay(1,29);
94 eval 'sub x7 :Dokay(0,30) {}' or ::ok(1,30);
99 sub TIESCALAR { ::ok(1,31); bless {}, $_[0] }
100 sub FETCH { ::ok(1,32); return 1 }
101 sub STORE { ::ok(1,33); return 1 }
105 sub TIEARRAY { ::ok(1,$_[1]); bless {}, $_[0] }
106 sub FETCH { ::ok(1,35); return 1 }
107 sub STORE { ::ok(1,36); return 1 }
108 sub FETCHSIZE { 100 }
112 sub TIEHASH { ::ok(1,$_[1]); bless {}, $_[0] }
113 sub FETCH { ::ok(1,38); return 1 }
114 sub STORE { ::ok(1,39); return 1 }
118 use Attribute::Handlers autotie => { Other::Loud => Tie::Loud,
120 UNIVERSAL::Rowdy => Tie::Rowdy,
123 my Other $loud : Loud;
126 my @noisy : Noisy(34);
129 my %rowdy : Rowdy(37);