File: 008_method_mod_args.t

package info (click to toggle)
libmoose-perl 1.09-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,004 kB
  • ctags: 1,472
  • sloc: perl: 25,387; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 572 bytes parent folder | download
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
use strict;
use warnings;

use Test::More;
use Test::Exception;
use Moose::Util qw( add_method_modifier );

my $COUNT = 0;
{
    package Foo;
    use Moose;

    sub foo { }
    sub bar { }
}

lives_ok {
    add_method_modifier('Foo', 'before', [ ['foo', 'bar'], sub { $COUNT++ } ]);
} 'method modifier with an arrayref';

dies_ok {
    add_method_modifier('Foo', 'before', [ {'foo' => 'bar'}, sub { $COUNT++ } ]);
} 'method modifier with a hashref';

my $foo = Foo->new;
$foo->foo;
$foo->bar;
is($COUNT, 2, "checking that the modifiers were installed.");


done_testing;