summaryrefslogtreecommitdiff
path: root/t/op/attrhand.t
blob: 996d57237519953ef46e0a5c99b8dfadc43b2d43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/perl -w

BEGIN {
    chdir 't' if -d 't';
    @INC = '../lib';
    require './test.pl';
    skip_all_if_miniperl("miniperl can't load attributes");
}

plan tests => 4;

# test for bug #38475: parsing errors with multiline attributes

package Antler;

use Attribute::Handlers;

sub TypeCheck :ATTR(CODE,RAWDATA) {
    ::ok(1);
}

sub WrongAttr :ATTR(CODE,RAWDATA) {
    ::ok(0);
}

sub CheckData :ATTR(RAWDATA) {
    # check that the $data element contains the given attribute parameters.

    if ($_[4] eq "12, 14") {
        ::ok(1)
    }
    else {
        ::ok(0)
    }
}

sub CheckEmptyValue :ATTR() {
    if (not defined $_[4]) {
        ::ok(1)
    }
    else {
        ::ok(0)
    }
}

package Deer;
use base 'Antler';

sub something : TypeCheck(
    QNET::Util::Object,
    QNET::Util::Object,
    QNET::Util::Object
) { #           WrongAttr (perl tokenizer bug)
    # keep this ^ lined up !
    return 42;
}

something();

sub c :CheckData(12, 14) {};

sub d1 :CheckEmptyValue() {};
sub d2 :CheckEmptyValue {};