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