Attribute-Lexical
view release on metacpan or search on metacpan
lib/Attribute/Lexical.pm view on Meta::CPAN
}
if($next) {
return $invocant->$next($target, @unhandled);
} else {
return @unhandled;
}
}."}
1;
" or die $@; }
sub _check_attribute_name($) {
croak "attribute name must be a string" unless is_string($_[0]);
croak "malformed attribute name" unless $_[0] =~ qr/\A
(?:SCALAR|ARRAY|HASH|CODE):
[A-Za-z_][0-9A-Za-z_]*
\z/x;
}
=head1 PACKAGE METHODS
All these methods are meant to be invoked on the C<Attribute::Lexical>
use warnings;
use strict;
use Test::More tests => 4;
BEGIN { $^H |= 0x20000 if "$]" < 5.008; }
sub foo { }
sub munge_caller(@) { [ @_[0,1,2,10] ] }
sub caller_here() { munge_caller(caller(0)) }
my @attributes;
sub atthandler { push @attributes, [ @_[0..2], munge_caller(@{$_[3]}) ] }
use Attribute::Lexical "CODE:c0", \&atthandler;
sub foo :c0; is_deeply $attributes[0], [\&foo,"c0",undef,caller_here()];
sub foo :c0(x); is_deeply $attributes[1], [\&foo,"c0","x",caller_here()];
sub bar() {
sub foo :c0; is_deeply $attributes[2], [\&foo,"c0",undef,caller_here()];
use Attribute::Lexical "CODE:c1", \&atthandler;
sub foo :c0; is_deeply $attributes[3], [\&foo,"c0",undef,caller_here()];
}
bar();
1;
( run in 0.267 second using v1.01-cache-2.11-cpan-65fba6d93b7 )