Skip to content

Commit

Permalink
Revert ". better check of keyword"
Browse files Browse the repository at this point in the history
This reverts commit a24ed4f.
  • Loading branch information
fcuny committed Nov 30, 2010
1 parent 5bda01b commit d560787
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
7 changes: 2 additions & 5 deletions lib/Dancer/Plugin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@ sub register($&) {
my ($keyword, $code) = @_;
my $plugin_name = caller();

$keyword =~ /^[a-zA-Z_]+[a-zA-Z0-9_]*$/
or croak "You can't use '$keyword', it is an invalid name (it should match ^[a-zA-Z_]+[a-zA-Z0-9_]*$ )";

if (grep { $_ eq $keyword } map { s/^(?:\$|%|&|@|\*)//; $_ } (@Dancer::EXPORT, @Dancer::EXPORT_OK)) {
croak "You can't use '$keyword', this is a reserved keyword";
if (grep { $_ eq $keyword } @Dancer::EXPORT) {
croak "You can't use $keyword, this is a reserved keyword";
}
while (my ($plugin, $keywords) = each %$_keywords) {
if (grep { $_->[0] eq $keyword } @$keywords) {
Expand Down
15 changes: 1 addition & 14 deletions t/15_plugins/05_keywords.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,7 @@ use Dancer::Plugin;

eval {register dance => sub {1};};
ok $@;
like $@, qr/You can't use 'dance', this is a reserved keyword/;

{
local @Dancer::EXPORT = (@Dancer::EXPORT, '&frobnicator');

eval {register 'frobnicator' => sub {1};};
ok $@;
like $@, qr/You can't use 'frobnicator', this is a reserved keyword/;

}

eval {register '1function' => sub {1};};
ok $@;
like $@, qr/You can't use '1function', it is an invalid name/;
like $@, qr/You can't use dance, this is a reserved keyword/;

done_testing;

0 comments on commit d560787

Please sign in to comment.