This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to Attribute::Handlers 0.81
[perl5.git] / lib / Attribute / Handlers / t / linerep.t
CommitLineData
cab6c672
DF
1#!perl
2
3BEGIN {
4 if ($ENV{PERL_CORE}) {
5 chdir 't' if -d 't';
6 @INC = '../lib';
7 }
8}
9
2560d050 10use Test::More tests => 18;
cab6c672
DF
11use Attribute::Handlers;
12
13sub Args : ATTR(CODE) {
14 my ($package, $symbol, $referent, $attr, $data, $phase, $filename, $linenum) = @_;
15 is( $package, 'main', 'package' );
16 is( $symbol, \*foo, 'symbol' );
17 is( $referent, \&foo, 'referent' );
18 is( $attr, 'Args', 'attr' );
2560d050
DC
19 is( ref $data, 'ARRAY', 'data' );
20 is( $data->[0], 'bar', 'data' );
cab6c672
DF
21 is( $phase, 'CHECK', 'phase' );
22 is( $filename, __FILE__, 'filename' );
2560d050 23 is( $linenum, 26, 'linenum' );
cab6c672
DF
24}
25
26sub foo :Args(bar) {}
27
e016bc2d
RGS
28my $ref;
29sub myref { $ref = shift; }
30my $b;
31eval "my \$bar :SArgs(grumpf); \$b = \\\$bar";
32is( $b, $ref, 'referent' );
cab6c672
DF
33
34sub SArgs : ATTR(SCALAR) {
35 my ($package, $symbol, $referent, $attr, $data, $phase, $filename, $linenum) = @_;
36 is( $package, 'main', 'package' );
37 is( $symbol, 'LEXICAL', 'symbol' );
e016bc2d 38 myref($referent);
cab6c672 39 is( $attr, 'SArgs', 'attr' );
2560d050
DC
40 is( ref $data, 'ARRAY', 'data' );
41 is( $data->[0], 'grumpf', 'data' );
cab6c672
DF
42 is( $phase, 'CHECK', 'phase' );
43 TODO: {
44 local $TODO = "Doesn't work correctly";
45 is( $filename, __FILE__, 'filename' );
2560d050 46 is( $linenum, 28, 'linenum' );
cab6c672
DF
47 }
48}