Skip to content

Commit

Permalink
prevent PPI::Normal->register from registering duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
wchristian committed Jan 20, 2017
1 parent 0f450ab commit a259c6a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 1 addition & 1 deletion lib/PPI/Normal.pm
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ sub register {
}

# Has it already been added?
if ( List::Util::any { $_ eq $function } ) {
if ( List::Util::any { $_ eq $function } map @{$_}, values %LAYER ) {
return 1;
}

Expand Down
1 change: 0 additions & 1 deletion t/09_normal.t
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,5 @@ NO_DOUBLE_REG: {
is $PPI::Normal::LAYER{2}[-1], "main::just_a_test_sub", "and find subs at right layer";
my $size = @{ $PPI::Normal::LAYER{2} };
ok( PPI::Normal->register( "main::just_a_test_sub", 2 ), "can add subs again" );
local $TODO = 'prevent duplicate registrations of normals';
is scalar @{ $PPI::Normal::LAYER{2} }, $size, "but sub isn't added twice";
}

0 comments on commit a259c6a

Please sign in to comment.