This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Get t/uni/cache.t working under minitest
[perl5.git] / t / op / attrhand.t
1 #!/usr/bin/perl -w
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = '../lib';
6     require './test.pl';
7     skip_all_if_miniperl("miniperl can't load attributes");
8 }
9
10 plan tests => 4;
11
12 # test for bug #38475: parsing errors with multiline attributes
13
14 package Antler;
15
16 use Attribute::Handlers;
17
18 sub TypeCheck :ATTR(CODE,RAWDATA) {
19     ::ok(1);
20 }
21
22 sub WrongAttr :ATTR(CODE,RAWDATA) {
23     ::ok(0);
24 }
25
26 sub CheckData :ATTR(RAWDATA) {
27     # check that the $data element contains the given attribute parameters.
28
29     if ($_[4] eq "12, 14") {
30         ::ok(1)
31     }
32     else {
33         ::ok(0)
34     }
35 }
36
37 sub CheckEmptyValue :ATTR() {
38     if (not defined $_[4]) {
39         ::ok(1)
40     }
41     else {
42         ::ok(0)
43     }
44 }
45
46 package Deer;
47 use base 'Antler';
48
49 sub something : TypeCheck(
50     QNET::Util::Object,
51     QNET::Util::Object,
52     QNET::Util::Object
53 ) { #           WrongAttr (perl tokenizer bug)
54     # keep this ^ lined up !
55     return 42;
56 }
57
58 something();
59
60 sub c :CheckData(12, 14) {};
61
62 sub d1 :CheckEmptyValue() {};
63 sub d2 :CheckEmptyValue {};