diff options
Diffstat (limited to 'lib/Module/Pluggable/t/12onlyregex.t')
-rw-r--r-- | lib/Module/Pluggable/t/12onlyregex.t | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/lib/Module/Pluggable/t/12onlyregex.t b/lib/Module/Pluggable/t/12onlyregex.t new file mode 100644 index 0000000000..eff6a16256 --- /dev/null +++ b/lib/Module/Pluggable/t/12onlyregex.t @@ -0,0 +1,65 @@ +#!perl -w + +use strict; +use FindBin; +use lib "$FindBin::Bin/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; + |