This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix for perl #112316: Wrong behavior regarding labels with same prefix
[perl5.git] / t / op / attrhand.t
CommitLineData
ef097d42
RGS
1#!/usr/bin/perl -w
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6 require './test.pl';
62e452a4 7 skip_all_if_miniperl("miniperl can't load attributes");
ef097d42
RGS
8}
9
b384a05d 10plan tests => 4;
ef097d42
RGS
11
12# test for bug #38475: parsing errors with multiline attributes
13
14package Antler;
15
16use Attribute::Handlers;
17
18sub TypeCheck :ATTR(CODE,RAWDATA) {
19 ::ok(1);
20}
21
22sub WrongAttr :ATTR(CODE,RAWDATA) {
23 ::ok(0);
24}
25
b384a05d
SB
26sub 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
37sub CheckEmptyValue :ATTR() {
38 if (not defined $_[4]) {
39 ::ok(1)
40 }
41 else {
42 ::ok(0)
43 }
44}
45
ef097d42
RGS
46package Deer;
47use base 'Antler';
48
49sub 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
58something();
b384a05d
SB
59
60sub c :CheckData(12, 14) {};
61
62sub d1 :CheckEmptyValue() {};
63sub d2 :CheckEmptyValue {};