File: debug.pl

package info (click to toggle)
libdevel-declare-perl 0.006000-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 296 kB
  • ctags: 238
  • sloc: perl: 1,605; ansic: 756; makefile: 25
file content (43 lines) | stat: -rw-r--r-- 825 bytes parent folder | download | duplicates (7)
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
use strict;
use warnings;

use Devel::Declare;

BEGIN {

  Devel::Declare->install_declarator(
    'DeclareTest', 'method', DECLARE_PACKAGE | DECLARE_PROTO,
    sub {
      my ($name, $proto) = @_;
      return 'my $self = shift;' unless defined $proto && $proto ne '@_';
      return 'my ($self'.(length $proto ? ", ${proto}" : "").') = @_;';
    },
    sub {
      my ($name, $proto, $sub, @rest) = @_;
      if (defined $name && length $name) {
        unless ($name =~ /::/) {
          $name = "DeclareTest::${name}";
        }
        no strict 'refs';
        *{$name} = $sub;
      }
      return wantarray ? ($sub, @rest) : $sub;
    }
  );

}

my ($test_method1, $test_method2, @test_list);

{
  package DeclareTest;

  method new {
  };

}

{ no strict;
  no warnings 'uninitialized';
  print @{"_<t/debug.pl"};
}