Commit | Line | Data |
---|---|---|
3f7169a2 RGS |
1 | #!perl -w |
2 | ||
3 | use strict; | |
4 | use FindBin; | |
5 | use lib "$FindBin::Bin/lib"; | |
6 | use Test::More tests => 10; | |
7 | ||
8 | { | |
9 | my $foo; | |
10 | ok($foo = MyTest->new()); | |
11 | ||
12 | my @plugins; | |
13 | my @expected = qw(MyTest::Plugin::Foo); | |
14 | ok(@plugins = sort $foo->plugins); | |
15 | is_deeply(\@plugins, \@expected); | |
16 | ||
17 | @plugins = (); | |
18 | ||
19 | ok(@plugins = sort MyTest->plugins); | |
20 | is_deeply(\@plugins, \@expected); | |
21 | } | |
22 | ||
23 | { | |
24 | my $foo; | |
25 | ok($foo = MyTestSub->new()); | |
26 | ||
27 | my @plugins; | |
28 | my @expected = qw(MyTest::Plugin::Foo); | |
29 | ok(@plugins = sort $foo->plugins); | |
30 | is_deeply(\@plugins, \@expected); | |
31 | ||
32 | @plugins = (); | |
33 | ||
34 | ok(@plugins = sort MyTestSub->plugins); | |
35 | is_deeply(\@plugins, \@expected); | |
36 | } | |
37 | ||
38 | package MyTest; | |
39 | ||
40 | use strict; | |
41 | use Module::Pluggable only => "MyTest::Plugin::Foo"; | |
42 | ||
43 | ||
44 | sub new { | |
45 | my $class = shift; | |
46 | return bless {}, $class; | |
47 | ||
48 | } | |
49 | ||
50 | package MyTestSub; | |
51 | ||
52 | use strict; | |
53 | use Module::Pluggable search_path => "MyTest::Plugin"; | |
54 | ||
55 | ||
56 | sub new { | |
57 | my $class = shift; | |
58 | my $self = bless {}, $class; | |
59 | ||
60 | $self->only("MyTest::Plugin::Foo"); | |
61 | ||
62 | return $self; | |
63 | } | |
64 | 1; |