Commit | Line | Data |
7dd7d008 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Devel::Declare; |
5 | |
6 | BEGIN { |
7 | |
8 | Devel::Declare->install_declarator( |
9 | 'DeclareTest', 'method', DECLARE_PACKAGE | DECLARE_PROTO, |
10 | sub { |
11 | my ($name, $proto) = @_; |
12 | return 'my $self = shift;' unless defined $proto && $proto ne '@_'; |
13 | return 'my ($self'.(length $proto ? ", ${proto}" : "").') = @_;'; |
14 | }, |
15 | sub { |
16 | my ($name, $proto, $sub, @rest) = @_; |
17 | if (defined $name && length $name) { |
18 | unless ($name =~ /::/) { |
19 | $name = "DeclareTest::${name}"; |
20 | } |
21 | no strict 'refs'; |
22 | *{$name} = $sub; |
23 | } |
24 | return wantarray ? ($sub, @rest) : $sub; |
25 | } |
26 | ); |
27 | |
28 | } |
29 | |
30 | my ($test_method1, $test_method2, @test_list); |
31 | |
32 | { |
33 | package DeclareTest; |
34 | |
35 | method new { |
36 | }; |
37 | |
38 | } |
39 | |
40 | { no strict; |
41 | no warnings 'uninitialized'; |
42 | print @{"_<t/debug.pl"}; |
43 | } |