Add another MOOSE_TEST_MD option, MooseX
[gitmo/Moose.git] / t / roles / method_modifiers.t
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4 use Test::More;
5 use Test::Fatal;
6
7 my $FooRole;
8 {
9     package Foo::Role;
10     use Moose::Role;
11     after foo => sub { $FooRole++ };
12 }
13
14 {
15     package Foo;
16     use Moose;
17     with 'Foo::Role';
18     sub foo { }
19 }
20
21 Foo->foo;
22 is($FooRole, 1, "modifier called");
23
24 my $BarRole;
25 {
26     package Bar::Role;
27     use Moose::Role;
28     after ['foo', 'bar'] => sub { $BarRole++ };
29 }
30
31 {
32     package Bar;
33     use Moose;
34     with 'Bar::Role';
35     sub foo { }
36     sub bar { }
37 }
38
39 Bar->foo;
40 is($BarRole, 1, "modifier called");
41 Bar->bar;
42 is($BarRole, 2, "modifier called");
43
44 my $BazRole;
45 {
46     package Baz::Role;
47     use Moose::Role;
48     after 'foo', 'bar' => sub { $BazRole++ };
49 }
50
51 {
52     package Baz;
53     use Moose;
54     with 'Baz::Role';
55     sub foo { }
56     sub bar { }
57 }
58
59 Baz->foo;
60 is($BazRole, 1, "modifier called");
61 Baz->bar;
62 is($BazRole, 2, "modifier called");
63
64 my $QuuxRole;
65 {
66     package Quux::Role;
67     use Moose::Role;
68     { our $TODO; local $TODO = "can't handle regexes yet";
69     ::is( ::exception {
70         after qr/foo|bar/ => sub { $QuuxRole++ }
71     }, undef );
72     }
73 }
74
75 {
76     package Quux;
77     use Moose;
78     with 'Quux::Role';
79     sub foo { }
80     sub bar { }
81 }
82
83 { local $TODO = "can't handle regexes yet";
84 Quux->foo;
85 is($QuuxRole, 1, "modifier called");
86 Quux->bar;
87 is($QuuxRole, 2, "modifier called");
88 }
89
90 done_testing;