Merge branch 'smartmatch' into blead
[p5sagit/p5-mst-13.2.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 }
8
9 plan tests => 4;
10
11 # test for bug #38475: parsing errors with multiline attributes
12
13 package Antler;
14
15 use Attribute::Handlers;
16
17 sub TypeCheck :ATTR(CODE,RAWDATA) {
18     ::ok(1);
19 }
20
21 sub WrongAttr :ATTR(CODE,RAWDATA) {
22     ::ok(0);
23 }
24
25 sub CheckData :ATTR(RAWDATA) {
26     # check that the $data element contains the given attribute parameters.
27
28     if ($_[4] eq "12, 14") {
29         ::ok(1)
30     }
31     else {
32         ::ok(0)
33     }
34 }
35
36 sub CheckEmptyValue :ATTR() {
37     if (not defined $_[4]) {
38         ::ok(1)
39     }
40     else {
41         ::ok(0)
42     }
43 }
44
45 package Deer;
46 use base 'Antler';
47
48 sub something : TypeCheck(
49     QNET::Util::Object,
50     QNET::Util::Object,
51     QNET::Util::Object
52 ) { #           WrongAttr (perl tokenizer bug)
53     # keep this ^ lined up !
54     return 42;
55 }
56
57 something();
58
59 sub c :CheckData(12, 14) {};
60
61 sub d1 :CheckEmptyValue() {};
62 sub d2 :CheckEmptyValue {};