This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove cpan/Pod-LaTeX and pod2latex utility
[perl5.git] / cpan / Module-Pluggable / t / 20dodgy_files.t
1 #!perl -w
2
3 BEGIN {
4     if ($^O eq 'VMS' || $^O eq 'VOS') {
5         print "1..0 # Skip: can't handle misspelled plugin names\n";
6         exit;
7     }
8 }
9
10 use strict;
11 use FindBin;
12 use Test::More;
13 use lib (($FindBin::Bin."/lib")=~/^(.*)$/);
14 use File::Spec::Functions qw(catfile);
15
16
17 my ($dodgy_file) = (catfile($FindBin::Bin, "lib", "OddTest", "Plugin", "-Dodgy.pm")=~/^(.*)$/);
18 unless (-f $dodgy_file) {
19         plan skip_all => "Can't handle misspelled plugin names\n";
20 } else {
21         plan tests => 5;
22 }
23
24
25 my $foo;
26 ok($foo = OddTest->new());
27
28 my @plugins;
29 my @expected = ('OddTest::Plugin::-Dodgy', 'OddTest::Plugin::Foo');
30 ok(@plugins = sort $foo->plugins);
31 is_deeply(\@plugins, \@expected, "is deeply");
32
33 my @odd_plugins;
34 my @odd_expected = qw(OddTest::Plugin::Foo);
35 ok(@odd_plugins = sort $foo->odd_plugins);
36 is_deeply(\@odd_plugins, \@odd_expected, "is deeply");
37
38
39 package OddTest::Pluggable;
40
41 use Data::Dumper;
42 use base qw(Module::Pluggable::Object);
43
44
45 sub find_files { 
46     my $self = shift;
47     my @files = $self->SUPER::find_files(@_);
48     return grep { !/(^|\/)-/ } $self->SUPER::find_files(@_) ;
49 }
50
51 package OddTest;
52
53 use strict;
54 use Module::Pluggable;
55
56
57 sub new {
58     my $class = shift;
59     return bless {}, $class;
60
61 }
62
63 sub 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
83 1;
84