Move is_valid_class_name into XS
[gitmo/Mouse.git] / t / 001_mouse / 403-method-modifiers.t
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4 use Test::More tests => 4;
5 use Test::Exception;
6
7 my @calls;
8 my ($before, $after, $around);
9
10 do {
11     package Role;
12     use Mouse::Role;
13
14     $before = sub {
15         push @calls, 'Role::foo:before';
16     };
17     before foo => $before;
18
19     $after = sub {
20         push @calls, 'Role::foo:after';
21     };
22     after foo => $after;
23
24     $around = sub {
25         my $orig = shift;
26         push @calls, 'Role::foo:around_before';
27         $orig->(@_);
28         push @calls, 'Role::foo:around_after';
29     };
30     around foo => $around;
31
32     no Mouse::Role;
33 };
34
35 is_deeply([Role->meta->get_before_method_modifiers('foo')], [$before]);
36 is_deeply([Role->meta->get_after_method_modifiers('foo')],  [$after]);
37 is_deeply([Role->meta->get_around_method_modifiers('foo')], [$around]);
38
39 do {
40     package Class;
41     use Mouse;
42     with 'Role';
43
44     sub foo {
45         push @calls, 'Class::foo';
46     }
47
48     no Mouse;
49 };
50
51 Class->foo;
52 is_deeply([splice @calls], [
53     'Role::foo:before',
54     'Role::foo:around_before',
55     'Class::foo',
56     'Role::foo:around_after',
57     'Role::foo:after',
58 ]);
59