Just to say it works, here are the modified test files.
For the sake of not having to rename all of the lexicals to make sense,
I just wrapped them up in closures and duplicated the tests again using
the extra sub...
I imagine you'll want to rename things to suit your preferences and such.
-=Chris
#!perl-wT
use strict;
use lib 't/lib';
use Test::More tests => 10;
{
my $foo;
ok($foo = MyTest->new());
my @plugins;
my @expected = qw(MyTest::Plugin::Bar MyTest::Plugin::Quux::Foo);
ok(@plugins = sort $foo->plugins);
is_deeply(\@plugins, \@expected);
@plugins = ();
ok(@plugins = sort MyTest->plugins);
is_deeply(\@plugins, \@expected);
}
{
my $foo;
ok($foo = MyTestSub->new());
my @plugins;
my @expected = qw(MyTest::Plugin::Bar MyTest::Plugin::Quux::Foo);
ok(@plugins = sort $foo->plugins);
is_deeply(\@plugins, \@expected);
@plugins = ();
ok(@plugins = sort MyTestSub->plugins);
is_deeply(\@plugins, \@expected);
}
package MyTest;
use strict;
use Module::Pluggable except => qr/MyTest::Plugin::Foo/;
sub new {
my $class = shift;
return bless {}, $class;
}
package MyTestSub;
use strict;
use Module::Pluggable search_path => "MyTest::Plugin";
sub new {
my $class = shift;
my $self = bless {}, $class;
$self->except(qr/MyTest::Plugin::Foo/);
return $self;
}
1;
#!perl-wT
use strict;
use lib 't/lib';
use Test::More tests => 10;
{
my $foo;
ok($foo = MyTest->new());
my @plugins;
my @expected = qw(MyTest::Plugin::Bar MyTest::Plugin::Quux::Foo);
ok(@plugins = sort $foo->plugins);
is_deeply(\@plugins, \@expected);
@plugins = ();
ok(@plugins = sort MyTest->plugins);
is_deeply(\@plugins, \@expected);
}
{
my $foo;
ok($foo = MyTestSub->new());
my @plugins;
my @expected = qw(MyTest::Plugin::Bar MyTest::Plugin::Quux::Foo);
ok(@plugins = sort $foo->plugins);
is_deeply(\@plugins, \@expected);
@plugins = ();
ok(@plugins = sort MyTestSub->plugins);
is_deeply(\@plugins, \@expected);
}
package MyTest;
use strict;
use Module::Pluggable except => [ "MyTest::Plugin::Foo" ];
sub new {
my $class = shift;
return bless {}, $class;
}
package MyTestSub;
use strict;
use Module::Pluggable search_path => "MyTest::Plugin";
sub new {
my $class = shift;
my $self = bless {}, $class;
$self->except(["MyTest::Plugin::Foo"]);
return $self;
}
1;
#!perl-wT
use strict;
use lib 't/lib';
use Test::More tests => 10;
{
my $foo;
ok($foo = MyTest->new());
my @plugins;
my @expected = qw(MyTest::Plugin::Bar MyTest::Plugin::Quux::Foo);
ok(@plugins = sort $foo->plugins);
is_deeply(\@plugins, \@expected);
@plugins = ();
ok(@plugins = sort MyTest->plugins);
is_deeply(\@plugins, \@expected);
}
{
my $foo;
ok($foo = MyTestSub->new());
my @plugins;
my @expected = qw(MyTest::Plugin::Bar MyTest::Plugin::Quux::Foo);
ok(@plugins = sort $foo->plugins);
is_deeply(\@plugins, \@expected);
@plugins = ();
ok(@plugins = sort MyTestSub->plugins);
is_deeply(\@plugins, \@expected);
}
package MyTest;
use strict;
use Module::Pluggable except => "MyTest::Plugin::Foo";
sub new {
my $class = shift;
return bless {}, $class;
}
package MyTestSub;
use strict;
use Module::Pluggable search_path => "MyTest::Plugin";
sub new {
my $class = shift;
my $self = bless {}, $class;
$self->except("MyTest::Plugin::Foo");
return $self;
}
1;
#!perl-wT
use strict;
use lib 't/lib';
use Test::More tests => 10;
{
my $foo;
ok($foo = MyTest->new());
my @plugins;
my @expected = qw(MyTest::Plugin::Foo);
ok(@plugins = sort $foo->plugins);
is_deeply(\@plugins, \@expected);
@plugins = ();
ok(@plugins = sort MyTest->plugins);
is_deeply(\@plugins, \@expected);
}
{
my $foo;
ok($foo = MyTestSub->new());
my @plugins;
my @expected = qw(MyTest::Plugin::Foo);
ok(@plugins = sort $foo->plugins);
is_deeply(\@plugins, \@expected);
@plugins = ();
ok(@plugins = sort MyTestSub->plugins);
is_deeply(\@plugins, \@expected);
}
package MyTest;
use strict;
use Module::Pluggable only => qr/MyTest::Plugin::Foo$/;
sub new {
my $class = shift;
return bless {}, $class;
}
package MyTestSub;
use strict;
use Module::Pluggable search_path => "MyTest::Plugin";
sub new {
my $class = shift;
my $self = bless {}, $class;
$self->only(qr/MyTest::Plugin::Foo$/);
return $self;
}
1;
#!perl-wT
use strict;
use lib 't/lib';
use Test::More tests => 10;
{
my $foo;
ok($foo = MyTest->new());
my @plugins;
my @expected = qw(MyTest::Plugin::Foo);
ok(@plugins = sort $foo->plugins);
is_deeply(\@plugins, \@expected);
@plugins = ();
ok(@plugins = sort MyTest->plugins);
is_deeply(\@plugins, \@expected);
}
{
my $foo;
ok($foo = MyTestSub->new());
my @plugins;
my @expected = qw(MyTest::Plugin::Foo);
ok(@plugins = sort $foo->plugins);
is_deeply(\@plugins, \@expected);
@plugins = ();
ok(@plugins = sort MyTestSub->plugins);
is_deeply(\@plugins, \@expected);
}
package MyTest;
use strict;
use Module::Pluggable only => [ "MyTest::Plugin::Foo" ];
sub new {
my $class = shift;
return bless {}, $class;
}
package MyTestSub;
use strict;
use Module::Pluggable search_path => "MyTest::Plugin";
sub new {
my $class = shift;
my $self = bless {}, $class;
$self->only(["MyTest::Plugin::Foo"]);
return $self;
}
1;
#!perl-wT
use strict;
use lib 't/lib';
use Test::More tests => 10;
{
my $foo;
ok($foo = MyTest->new());
my @plugins;
my @expected = qw(MyTest::Plugin::Foo);
ok(@plugins = sort $foo->plugins);
is_deeply(\@plugins, \@expected);
@plugins = ();
ok(@plugins = sort MyTest->plugins);
is_deeply(\@plugins, \@expected);
}
{
my $foo;
ok($foo = MyTestSub->new());
my @plugins;
my @expected = qw(MyTest::Plugin::Foo);
ok(@plugins = sort $foo->plugins);
is_deeply(\@plugins, \@expected);
@plugins = ();
ok(@plugins = sort MyTestSub->plugins);
is_deeply(\@plugins, \@expected);
}
package MyTest;
use strict;
use Module::Pluggable only => "MyTest::Plugin::Foo";
sub new {
my $class = shift;
return bless {}, $class;
}
package MyTestSub;
use strict;
use Module::Pluggable search_path => "MyTest::Plugin";
sub new {
my $class = shift;
my $self = bless {}, $class;
$self->only("MyTest::Plugin::Foo");
return $self;
}
1;