diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-06-06 17:50:16 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-06-06 17:50:16 +0000 |
commit | 5ac2026f7eed78958d69d051e7a8e993dcf51205 (patch) | |
tree | 298c3d2f08bdfe5689998b11892d72a897985be1 /t/roles/method_modifiers.t | |
download | Moose-tarball-5ac2026f7eed78958d69d051e7a8e993dcf51205.tar.gz |
Moose-2.1405HEADMoose-2.1405master
Diffstat (limited to 't/roles/method_modifiers.t')
-rw-r--r-- | t/roles/method_modifiers.t | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/t/roles/method_modifiers.t b/t/roles/method_modifiers.t new file mode 100644 index 0000000..b3076a6 --- /dev/null +++ b/t/roles/method_modifiers.t @@ -0,0 +1,89 @@ +use strict; +use warnings; +use Test::More; +use Test::Fatal; + +my $FooRole; +{ + package Foo::Role; + use Moose::Role; + after foo => sub { $FooRole++ }; +} + +{ + package Foo; + use Moose; + with 'Foo::Role'; + sub foo { } +} + +Foo->foo; +is($FooRole, 1, "modifier called"); + +my $BarRole; +{ + package Bar::Role; + use Moose::Role; + after ['foo', 'bar'] => sub { $BarRole++ }; +} + +{ + package Bar; + use Moose; + with 'Bar::Role'; + sub foo { } + sub bar { } +} + +Bar->foo; +is($BarRole, 1, "modifier called"); +Bar->bar; +is($BarRole, 2, "modifier called"); + +my $BazRole; +{ + package Baz::Role; + use Moose::Role; + after 'foo', 'bar' => sub { $BazRole++ }; +} + +{ + package Baz; + use Moose; + with 'Baz::Role'; + sub foo { } + sub bar { } +} + +Baz->foo; +is($BazRole, 1, "modifier called"); +Baz->bar; +is($BazRole, 2, "modifier called"); + +my $QuuxRole; +{ + package Quux::Role; + use Moose::Role; + { our $TODO; local $TODO = "can't handle regexes yet"; + ::is( ::exception { + after qr/foo|bar/ => sub { $QuuxRole++ } + }, undef ); + } +} + +{ + package Quux; + use Moose; + with 'Quux::Role'; + sub foo { } + sub bar { } +} + +{ local $TODO = "can't handle regexes yet"; +Quux->foo; +is($QuuxRole, 1, "modifier called"); +Quux->bar; +is($QuuxRole, 2, "modifier called"); +} + +done_testing; |