Commit | Line | Data |
775666aa |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
b10dde3a |
5 | use Test::Fatal; |
775666aa |
6 | use Moose::Util qw( add_method_modifier ); |
7 | |
8 | my $COUNT = 0; |
9 | { |
10 | package Foo; |
11 | use Moose; |
12 | |
13 | sub foo { } |
14 | sub bar { } |
15 | } |
16 | |
b10dde3a |
17 | is( exception { |
775666aa |
18 | add_method_modifier('Foo', 'before', [ ['foo', 'bar'], sub { $COUNT++ } ]); |
b10dde3a |
19 | }, undef, 'method modifier with an arrayref' ); |
775666aa |
20 | |
b10dde3a |
21 | isnt( exception { |
775666aa |
22 | add_method_modifier('Foo', 'before', [ {'foo' => 'bar'}, sub { $COUNT++ } ]); |
b10dde3a |
23 | }, undef, 'method modifier with a hashref' ); |
775666aa |
24 | |
25 | my $foo = Foo->new; |
26 | $foo->foo; |
27 | $foo->bar; |
28 | is($COUNT, 2, "checking that the modifiers were installed."); |
29 | |
30 | |
31 | done_testing; |