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/exceptions/class-mop-mixin-hasmethods.t | |
download | Moose-tarball-5ac2026f7eed78958d69d051e7a8e993dcf51205.tar.gz |
Moose-2.1405HEADMoose-2.1405master
Diffstat (limited to 't/exceptions/class-mop-mixin-hasmethods.t')
-rw-r--r-- | t/exceptions/class-mop-mixin-hasmethods.t | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/t/exceptions/class-mop-mixin-hasmethods.t b/t/exceptions/class-mop-mixin-hasmethods.t new file mode 100644 index 0000000..d0d39dd --- /dev/null +++ b/t/exceptions/class-mop-mixin-hasmethods.t @@ -0,0 +1,141 @@ +use strict; +use warnings; + +use Test::More; +use Test::Fatal; + +use Moose(); + +{ + { + package Foo; + use Moose::Role; + } + + my $exception = exception { + Foo->meta->has_method; + }; + + like( + $exception, + qr/\QYou must define a method name/, + "no method name is given"); + + isa_ok( + $exception, + "Moose::Exception::MustDefineAMethodName", + "no method name is given"); + + is( + $exception->instance, + Foo->meta, + "no method name is given"); +} + +{ + { + package Foo; + use Moose::Role; + } + + my $exception = exception { + Foo->meta->add_method; + }; + + like( + $exception, + qr/\QYou must define a method name/, + "no method name is given"); + + isa_ok( + $exception, + "Moose::Exception::MustDefineAMethodName", + "no method name is given"); + + is( + $exception->instance, + Foo->meta, + "no method name is given"); +} + +{ + { + package Foo; + use Moose::Role; + } + + my $exception = exception { + Foo->meta->get_method; + }; + + like( + $exception, + qr/\QYou must define a method name/, + "no method name is given"); + + isa_ok( + $exception, + "Moose::Exception::MustDefineAMethodName", + "no method name is given"); + + is( + $exception->instance, + Foo->meta, + "no method name is given"); +} + +{ + { + package Foo; + use Moose::Role; + } + + my $exception = exception { + Foo->meta->remove_method; + }; + + like( + $exception, + qr/\QYou must define a method name/, + "no method name is given"); + + isa_ok( + $exception, + "Moose::Exception::MustDefineAMethodName", + "no method name is given"); + + is( + $exception->instance, + Foo->meta, + "no method name is given"); +} + +{ + { + package Bar::Role; + use Moose::Role; + } + + my $meta = Bar::Role->meta; + + my $exception = exception { + $meta->wrap_method_body; + }; + + like( + $exception, + qr/Your code block must be a CODE reference/, + "no arguments passed to wrap_method_body"); + + isa_ok( + $exception, + "Moose::Exception::CodeBlockMustBeACodeRef", + "no arguments passed to wrap_method_body"); + + is( + $exception->instance, + $meta, + "no arguments passed to wrap_method_body"); +} + +done_testing; |