From: Shawn M Moore Date: Mon, 8 Dec 2008 01:16:00 +0000 (+0000) Subject: Throw an error if there's no parameter name provided X-Git-Tag: 0.05~34 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=396466d48ca8d79a727cb7618d2a15ab1c0a1a78;p=gitmo%2FMooseX-Role-Parameterized.git Throw an error if there's no parameter name provided --- diff --git a/lib/MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm b/lib/MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm index 6718cc6..a7c7e58 100644 --- a/lib/MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm +++ b/lib/MooseX/Role/Parameterized/Meta/Role/Parameterizable.pm @@ -28,6 +28,9 @@ sub add_parameter { my $self = shift; my $name = shift; + confess "You must provide a name for the parameter" + if !defined($name); + # need to figure out a plan for these guys.. confess "The parameter name ($name) is currently forbidden." if $name eq 'alias' diff --git a/t/100-erroneous-keywords.t b/t/100-erroneous-keywords.t index 3405cc2..fabcecf 100644 --- a/t/100-erroneous-keywords.t +++ b/t/100-erroneous-keywords.t @@ -1,7 +1,7 @@ #!/usr/bin/env perl use strict; use warnings; -use Test::More tests => 3; +use Test::More tests => 4; use Test::Exception; @@ -9,6 +9,10 @@ do { package MyRole::Storage; use MooseX::Role::Parameterized; + ::throws_ok { + parameter() + } qr/^You must provide a name for the parameter/; + role { ::throws_ok { extends 'MyRole::Parameterized';