File: simple.t

package info (click to toggle)
libdevel-declare-perl 0.006017-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 376 kB
  • sloc: ansic: 752; perl: 608; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 635 bytes parent folder | download | duplicates (3)
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
use strict;
use warnings;
use Test::More;

sub method {
  my ($usepack, $name, $inpack, $sub) = @_;
  no strict 'refs';
  *{"${inpack}::${name}"} = $sub;
}

sub handle_method {
  my ($usepack, $use, $inpack, $name) = @_;
  return sub (&) { ($usepack, $name, $inpack, $_[0]); };
}

use Devel::Declare 'method' => \&handle_method;

my ($args1, $args2);

method bar {
  $args1 = join(', ', @_);
};

method # blather
  baz
  # whee
{ # fweet
  $args2 = join(', ', @_);
};

__PACKAGE__->bar(qw(1 2));
__PACKAGE__->baz(qw(3 4));

is($args1, 'main, 1, 2', 'Method bar args ok');
is($args2, 'main, 3, 4', 'Method baz args ok');

done_testing;