1*b39c5158Smillert#!perl
2*b39c5158Smillert
3*b39c5158Smillertuse Test::More tests => 18;
4*b39c5158Smillertuse Attribute::Handlers;
5*b39c5158Smillert
6*b39c5158Smillertsub Args : ATTR(CODE) {
7*b39c5158Smillert    my ($package, $symbol, $referent, $attr, $data, $phase, $filename, $linenum) = @_;
8*b39c5158Smillert    is( $package,	'main',		'package' );
9*b39c5158Smillert    is( $symbol,	\*foo,		'symbol' );
10*b39c5158Smillert    is( $referent,	\&foo,		'referent' );
11*b39c5158Smillert    is( $attr,		'Args',		'attr' );
12*b39c5158Smillert    is( ref $data,	'ARRAY',	'data' );
13*b39c5158Smillert    is( $data->[0],	'bar',		'data' );
14*b39c5158Smillert    is( $phase,		'CHECK',	'phase' );
15*b39c5158Smillert    is( $filename,	__FILE__,	'filename' );
16*b39c5158Smillert    is( $linenum,	19,		'linenum' );
17*b39c5158Smillert}
18*b39c5158Smillert
19*b39c5158Smillertsub foo :Args(bar) {}
20*b39c5158Smillert
21*b39c5158Smillertmy $ref;
22*b39c5158Smillertsub myref { $ref = shift; }
23*b39c5158Smillertmy $b;
24*b39c5158Smillert#line 42
25*b39c5158Smillerteval "my \$bar :SArgs(grumpf); \$b = \\\$bar";
26*b39c5158Smillertis( $b, $ref, 'referent' );
27*b39c5158Smillert
28*b39c5158Smillertsub SArgs : ATTR(SCALAR) {
29*b39c5158Smillert    my ($package, $symbol, $referent, $attr, $data, $phase, $filename, $linenum) = @_;
30*b39c5158Smillert    is( $package,	'main',		'package' );
31*b39c5158Smillert    is( $symbol,	'LEXICAL',	'symbol' );
32*b39c5158Smillert    myref($referent);
33*b39c5158Smillert    is( $attr,		'SArgs',	'attr' );
34*b39c5158Smillert    is( ref $data,	'ARRAY',	'data' );
35*b39c5158Smillert    is( $data->[0],	'grumpf',	'data' );
36*b39c5158Smillert    is( $phase,		'CHECK',	'phase' );
37*b39c5158Smillert    TODO: {
38*b39c5158Smillert      local $TODO = "Doesn't work correctly" if $] < 5.008;
39*b39c5158Smillert      is( $filename,	__FILE__,	'filename' );
40*b39c5158Smillert      is( $linenum,	42,		'linenum' );
41*b39c5158Smillert    }
42*b39c5158Smillert}
43