Skip to content

Commit

Permalink
Fix more hash ordering bugs in tests by forcing sort of returned plug…
Browse files Browse the repository at this point in the history
…ins (Yves Orton)
  • Loading branch information
simonwistow committed Feb 26, 2013
1 parent 16fa007 commit 70ef1fa
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2013-02-25 - 4.7
Fix more hash ordering bugs in tests by forcing sort of returned plugins (Yves Orton)

2013-01-23 - 4.6
Add warning about future removal from core

Expand Down
2 changes: 1 addition & 1 deletion lib/Module/Pluggable.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use if $] > 5.017, 'deprecate';
# Peter Gibbons: I wouldn't say I've been missing it, Bob!


$VERSION = '4.6'; # core release only!
$VERSION = '4.7';
$FORCE_SEARCH_ALL_PATHS = 0;

sub import {
Expand Down
9 changes: 5 additions & 4 deletions lib/Module/Pluggable/Object.pm
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,17 @@ sub plugins {
if (defined $self->{'instantiate'}) {
my $method = $self->{'instantiate'};
my @objs = ();
foreach my $package (keys %plugins) {
next unless $package->can($method);
foreach my $package (sort keys %plugins) {
next unless $package->can($method);
my $obj = eval { $package->$method(@_) };
$self->{'on_instantiate_error'}->($package, $@) if $@;
$self->{'on_instantiate_error'}->($package, $@) if $@;
push @objs, $obj if $obj;
}
return @objs;
} else {
# no? just return the names
return keys %plugins;
my @objs= sort keys %plugins;
return @objs;
}
}

Expand Down
8 changes: 4 additions & 4 deletions t/19can_ok_clobber.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use Test::More tests=>5;
#use_ok( 'MyTest' );
#diag "Module::Pluggable::VERSION $Module::Pluggable::VERSION";

my @plugins = MyTest->plugins;
my @plugins = sort MyTest->plugins;
my @plugins_after;

use_ok( 'MyTest::Plugin::Foo' );
Expand All @@ -21,16 +21,16 @@ is_deeply(
\@plugins_after,
\@plugins,
"plugins haven't been clobbered",
);
) or diag Dumper(\@plugins_after,\@plugins);

can_ok ($foo, 'frobnitz');

@plugins_after = MyTest->plugins;
@plugins_after = sort MyTest->plugins;
is_deeply(
\@plugins_after,
\@plugins,
"plugins haven't been clobbered",
) or diag Dumper ;
) or diag Dumper(\@plugins_after,\@plugins);



Expand Down

0 comments on commit 70ef1fa

Please sign in to comment.