Commit | Line | Data |
---|---|---|
11fd7d05 | 1 | #!/usr/bin/perl -wT |
9e8c31cc MS |
2 | |
3 | BEGIN { | |
11fd7d05 RGS |
4 | if( $ENV{PERL_CORE} ) { |
5 | chdir 't'; | |
6 | @INC = '../lib'; | |
dbb032c1 | 7 | } |
9e8c31cc MS |
8 | } |
9 | ||
11fd7d05 RGS |
10 | use strict; |
11 | use Config; | |
12 | use Test::More; | |
13 | my %modules; | |
14 | BEGIN { | |
15 | %modules = ( | |
16 | # ModuleName => q|code to check that it was loaded|, | |
17 | 'Cwd' => q| ::is( ref Cwd->can('fastcwd'),'CODE' ) |, # 5.7 ? | |
18 | 'File::Glob' => q| ::is( ref File::Glob->can('doglob'),'CODE' ) |, # 5.6 | |
19 | 'SDBM_File' => q| ::is( ref SDBM_File->can('TIEHASH'), 'CODE' ) |, # 5.0 | |
20 | 'Socket' => q| ::is( ref Socket->can('inet_aton'),'CODE' ) |, # 5.0 | |
21 | 'Time::HiRes'=> q| ::is( ref Time::HiRes->can('usleep'),'CODE' ) |, # 5.7.3 | |
22 | ); | |
23 | plan tests => keys(%modules) * 2 + 3 | |
24 | } | |
25 | ||
26 | ||
27 | BEGIN { | |
28 | use_ok( 'XSLoader' ); | |
29 | } | |
30 | ||
31 | # Check functions | |
32 | can_ok( 'XSLoader' => 'load' ); | |
33 | #can_ok( 'XSLoader' => 'bootstrap_inherit' ); # doesn't work | |
34 | ||
35 | # Check error messages | |
36 | eval { XSLoader::load() }; | |
37 | like( $@, '/^XSLoader::load\(\'Your::Module\', \$Your::Module::VERSION\)/', | |
38 | "calling XSLoader::load() with no argument" ); | |
9e8c31cc | 39 | |
11fd7d05 RGS |
40 | # Now try to load well known XS modules |
41 | my $extensions = $Config{'extensions'}; | |
42 | $extensions =~ s|/|::|g; | |
9e8c31cc | 43 | |
11fd7d05 RGS |
44 | for my $module (sort keys %modules) { |
45 | SKIP: { | |
46 | skip "$module not available", 2 if $extensions !~ /\b$module\b/; | |
47 | eval qq| package $module; XSLoader::load('$module'); | . $modules{$module}; | |
48 | is( $@, '', "XSLoader::load($module)"); | |
49 | } | |
50 | } | |
9e8c31cc | 51 |