1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
#!/usr/bin/perl -w
use strict;
use warnings;
use Test::More 'no_plan';
use attributes;
{
package Stuff;
use Test::More;
use Method::Signatures;
method echo : method ($arg) {
return $arg;
}
is( Stuff->echo(42), 42 );
is_deeply( [attributes::get \&echo], ['method'] );
}
{
package Foo;
use Test::More;
use Method::Signatures;
my $code = func : method () {};
is_deeply( [attributes::get $code], ['method'] );
}
{
package Things;
use attributes;
use Method::Signatures;
my $attrs;
my $cb_called;
sub MODIFY_CODE_ATTRIBUTES {
my ($pkg, $code, @attrs) = @_;
$cb_called = 1;
$attrs = \@attrs;
return ();
}
method moo : Bar Baz(fubar) ($foo, $bar) {
}
# Torture test for the attribute handling.
method foo
:
Bar
:Moo(:Ko{oh)
: Baz(fu{bar:): ($foo, $bar) { return {} }
::ok($cb_called, 'attribute handler got called');
::is_deeply($attrs, [qw/Bar Moo(:Ko{oh) Baz(fu{bar:)/], '... with the right attributes');
}
|