Move Module::Pluggable tests up under main test directory.
[p5sagit/p5-mst-13.2.git] / t / Module_Pluggable / 20dodgy_files.t
CommitLineData
3f7169a2 1#!perl -w
2
8f75121c 3BEGIN {
4 if ($^O eq 'VMS') {
5 print "1..0 # Skip: can't handle misspelled plugin names\n";
6 exit;
7 }
8}
9
3f7169a2 10use strict;
11use FindBin;
12use lib "$FindBin::Bin/lib";
13use Test::More tests => 5;
14
15my $foo;
16ok($foo = OddTest->new());
17
18my @plugins;
19my @expected = ('OddTest::Plugin::-Dodgy', 'OddTest::Plugin::Foo');
20ok(@plugins = sort $foo->plugins);
21is_deeply(\@plugins, \@expected, "is deeply");
22
23my @odd_plugins;
24my @odd_expected = qw(OddTest::Plugin::Foo);
25ok(@odd_plugins = sort $foo->odd_plugins);
26is_deeply(\@odd_plugins, \@odd_expected, "is deeply");
27
28
29package OddTest::Pluggable;
30
31use Data::Dumper;
32use base qw(Module::Pluggable::Object);
33
34
35sub find_files {
36 my $self = shift;
37 my @files = $self->SUPER::find_files(@_);
38 return grep { !/(^|\/)-/ } $self->SUPER::find_files(@_) ;
39}
40
41package OddTest;
42
43use strict;
44use Module::Pluggable;
45
46
47sub new {
48 my $class = shift;
49 return bless {}, $class;
50
51}
52
53sub odd_plugins {
54 my $self = shift;
55 my %opts;
56 my ($pkg, $file) = caller;
57 # the default name for the method is 'plugins'
58 my $sub = $opts{'sub_name'} || 'plugins';
59 # get our package
60 my ($package) = $opts{'package'} || "OddTest";
61 $opts{filename} = $file;
62 $opts{package} = $package;
63
64
65
66 my $op = OddTest::Pluggable->new( package => ref($self) );
67 return $op->plugins(@_);
68
69
70}
71
72
731;
74