This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Strip whitespace from the beginning of static_ext:
[perl5.git] / t / Module_Pluggable / 07instantiate.t
1 #!perl -w
2
3 use strict;
4 use FindBin;
5 use lib "$FindBin::Bin/lib";
6 use Test::More tests => 6;
7
8 my $foo;
9 ok($foo = MyTest->new());
10
11
12
13 my @plugins;
14 ok(@plugins = sort $foo->booga(nork => 'fark'));
15 is(ref $plugins[0],'MyTest::Extend::Plugin::Bar');
16 is($plugins[0]->nork,'fark');
17
18
19 @plugins = ();
20 eval { @plugins = $foo->wooga( nork => 'fark') };
21 is($@, '');
22 is(scalar(@plugins),0);
23
24
25 package MyTest;
26 use File::Spec::Functions qw(catdir);
27 use strict;
28 use FindBin;
29 use lib "$FindBin::Bin/lib";
30 use Module::Pluggable (search_path => ["MyTest::Extend::Plugin"], sub_name => 'booga', instantiate => 'new');
31 use Module::Pluggable (search_path => ["MyTest::Extend::Plugin"], sub_name => 'wooga', instantiate => 'nosomuchmethod');
32
33
34 sub new {
35     my $class = shift;
36     return bless {}, $class;
37
38 }
39 1;
40