1 ### Module::Load test suite ###
3 if( $ENV{PERL_CORE} ) {
4 chdir '../lib/Module/Load' if -d '../lib/Module/Load';
5 unshift @INC, '../../..';
9 BEGIN { chdir 't' if -d 't' }
12 use lib qw[../lib to_load];
14 use Test::More 'no_plan';
16 ### test loading files & modules
18 # module flag diagnostic
19 [q|Must::Be::Loaded|, 1, 'module'],
20 [q|LoadMe.pl|, 0, 'file' ],
21 [q|LoadIt|, 1, 'ambiguous module' ],
22 [q|ToBeLoaded|, 0, 'ambiguous file' ],
26 my($mod, $flag, $diag) = @$aref;
28 my $file = Module::Load::_to_file($mod, $flag);
32 is( $@, '', qq[Loading $diag '$mod' $@] );
33 ok( defined($INC{$file}), qq[ '$file' found in \%INC] );
37 ### Test importing functions ###
38 { my $mod = 'TestModule';
39 my @funcs = qw[func1 func2];
41 eval { load $mod, @funcs };
42 is( $@, '', qq[Loaded exporter module '$mod'] );
44 ### test if import gets called properly
45 ok( $mod->imported, " ->import() was called" );
47 ### test if functions get exported
48 for my $func (@funcs) {
49 ok( $mod->can($func), " $mod->can( $func )" );
50 ok( __PACKAGE__->can($func), " we ->can ( $func )" );