[patch@31735] Module-load/require fixes for VMS
[p5sagit/p5-mst-13.2.git] / lib / Module / Load / t / 01_Module-Load.t
1 ### Module::Load test suite ###
2 BEGIN { 
3     if( $ENV{PERL_CORE} ) {
4         chdir '../lib/Module/Load' if -d '../lib/Module/Load';
5         unshift @INC, '../../..';
6     }
7
8
9 BEGIN { chdir 't' if -d 't' }
10
11 use strict;
12 use lib qw[../lib to_load];
13 use Module::Load;
14 use Test::More tests => 13;
15
16
17 {
18     my $mod = 'Must::Be::Loaded';
19     my $file = Module::Load::_to_file($mod,1);
20
21     # %INC on VMS has all keys in UNIX format
22     $file = VMS::Filespec::unixify($file) if $^O eq 'VMS';
23
24     eval { load $mod };
25
26     is( $@, '', qq[Loading module '$mod'] );
27     ok( defined($INC{$file}), q[... found in %INC] );
28 }
29
30 {
31     my $mod = 'LoadMe.pl';
32     my $file = Module::Load::_to_file($mod);
33
34     eval { load $mod };
35
36     is( $@, '', qq[Loading File '$mod'] );
37     ok( defined($INC{$file}), q[... found in %INC] );
38 }
39
40 {
41     my $mod = 'LoadIt';
42     my $file = Module::Load::_to_file($mod,1);
43
44     eval { load $mod };
45
46     is( $@, '', qq[Loading Ambigious Module '$mod'] );
47     ok( defined($INC{$file}), q[... found in %INC] );
48 }
49
50 {
51     my $mod = 'ToBeLoaded';
52     my $file = Module::Load::_to_file($mod);
53
54     eval { load $mod };
55
56     is( $@, '', qq[Loading Ambigious File '$mod'] );
57     ok( defined($INC{$file}), q[... found in %INC] );
58 }
59
60 ### Test importing functions ###
61 {   my $mod     = 'TestModule';
62     my @funcs   = qw[func1 func2];
63     
64     eval { load $mod, @funcs };
65     is( $@, '', qq[Loaded exporter module '$mod'] );
66     
67     for my $func (@funcs) {
68         ok( $mod->can($func),           "$mod -> can( $func )" );
69         ok( __PACKAGE__->can($func),    "we -> can ( $func )"  ); 
70     }        
71 }