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