The correct name of PERL_UTF8_magic is PERL_MAGIC_utf8, so use it in sv.c apidocs
[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 'no_plan';
15
16 ### test loading files & modules
17 {   my @Map = (
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'    ],
23     );
24
25     for my $aref (@Map) {
26         my($mod, $flag, $diag) = @$aref;
27
28         my $file = Module::Load::_to_file($mod, $flag);
29
30         eval { load $mod };
31
32         is( $@, '',                 qq[Loading $diag '$mod' $@] );
33         ok( defined($INC{$file}),   qq[  '$file' found in \%INC] );
34     }
35 }
36
37 ### Test importing functions ###
38 {   my $mod     = 'TestModule';
39     my @funcs   = qw[func1 func2];
40
41     eval { load $mod, @funcs };
42     is( $@, '', qq[Loaded exporter module '$mod'] );
43
44     ### test if import gets called properly
45     ok( $mod->imported,                 "   ->import() was called" );
46
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 )" );
51     }
52 }