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