From: Shawn M Moore Date: Tue, 25 Nov 2008 06:55:17 +0000 (+0000) Subject: Implement a few more keywords; these are easy, they're just errors :) X-Git-Tag: 0.05~74 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fc4a95b67fb93b9b80dfbf0c9e6663cf3dccb602;p=gitmo%2FMooseX-Role-Parameterized.git Implement a few more keywords; these are easy, they're just errors :) --- diff --git a/lib/MooseX/Role/Parameterized.pm b/lib/MooseX/Role/Parameterized.pm index 80ba9c5..24152fe 100644 --- a/lib/MooseX/Role/Parameterized.pm +++ b/lib/MooseX/Role/Parameterized.pm @@ -1,8 +1,13 @@ #!/usr/bin/env perl package MooseX::Role::Parameterized; -use Moose qw/extends around confess/; +use Moose ( + extends => { -as => 'moose_extends' }, + qw/around confess/, +); + +use Carp 'croak'; use Moose::Role (); -extends 'Moose::Exporter'; +moose_extends 'Moose::Exporter'; use MooseX::Role::Parameterized::Meta::Role::Parameterizable; @@ -10,7 +15,7 @@ our $CURRENT_METACLASS; __PACKAGE__->setup_import_methods( with_caller => ['parameter', 'role', 'method'], - as_is => ['has'], + as_is => ['has', 'extends', 'augment', 'inner'], ); sub parameter { @@ -79,5 +84,11 @@ sub method { $CURRENT_METACLASS->add_method($name => $method); } +sub extends { croak "Roles do not currently support 'extends'" } + +sub inner { croak "Roles cannot support 'inner'" } + +sub augment { croak "Roles cannot support 'augment'" } + 1; diff --git a/t/100-erroneous-keywords.t b/t/100-erroneous-keywords.t new file mode 100644 index 0000000..3405cc2 --- /dev/null +++ b/t/100-erroneous-keywords.t @@ -0,0 +1,28 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More tests => 3; + +use Test::Exception; + +do { + package MyRole::Storage; + use MooseX::Role::Parameterized; + + role { + ::throws_ok { + extends 'MyRole::Parameterized'; + } qr/^Roles do not currently support 'extends'/; + ::throws_ok { + inner() + } qr/^Roles cannot support 'inner'/; + ::throws_ok { + augment() + } qr/^Roles cannot support 'augment'/; + }; +}; + +Moose::Meta::Class->create_anon_class( + roles => ['MyRole::Storage'], +); +