This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
patch@32274 t/op/taint.t not cleaning up properly on VMS.
[perl5.git] / t / Module_Pluggable / 20dodgy_files.t
1 #!perl -w
2
3 BEGIN {
4     if ($^O eq 'VMS') {
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 lib "$FindBin::Bin/lib";
13 use Test::More tests => 5;
14
15 my $foo;
16 ok($foo = OddTest->new());
17
18 my @plugins;
19 my @expected = ('OddTest::Plugin::-Dodgy', 'OddTest::Plugin::Foo');
20 ok(@plugins = sort $foo->plugins);
21 is_deeply(\@plugins, \@expected, "is deeply");
22
23 my @odd_plugins;
24 my @odd_expected = qw(OddTest::Plugin::Foo);
25 ok(@odd_plugins = sort $foo->odd_plugins);
26 is_deeply(\@odd_plugins, \@odd_expected, "is deeply");
27
28
29 package OddTest::Pluggable;
30
31 use Data::Dumper;
32 use base qw(Module::Pluggable::Object);
33
34
35 sub find_files { 
36     my $self = shift;
37     my @files = $self->SUPER::find_files(@_);
38     return grep { !/(^|\/)-/ } $self->SUPER::find_files(@_) ;
39 }
40
41 package OddTest;
42
43 use strict;
44 use Module::Pluggable;
45
46
47 sub new {
48     my $class = shift;
49     return bless {}, $class;
50
51 }
52
53 sub 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
73 1;
74