Avoid undefined behaviour for -DPERL_MEM_LOG by not using a direct
[p5sagit/p5-mst-13.2.git] / ext / DynaLoader / t / XSLoader.t
CommitLineData
11fd7d05 1#!/usr/bin/perl -wT
9e8c31cc 2
3BEGIN {
11fd7d05 4 if( $ENV{PERL_CORE} ) {
5 chdir 't';
6 @INC = '../lib';
dbb032c1 7 }
9e8c31cc 8}
9
11fd7d05 10use strict;
11use Config;
12use Test::More;
13my %modules;
14BEGIN {
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
27BEGIN {
28 use_ok( 'XSLoader' );
29}
30
31# Check functions
32can_ok( 'XSLoader' => 'load' );
33#can_ok( 'XSLoader' => 'bootstrap_inherit' ); # doesn't work
34
35# Check error messages
36eval { XSLoader::load() };
37like( $@, '/^XSLoader::load\(\'Your::Module\', \$Your::Module::VERSION\)/',
38 "calling XSLoader::load() with no argument" );
9e8c31cc 39
11fd7d05 40# Now try to load well known XS modules
41my $extensions = $Config{'extensions'};
42$extensions =~ s|/|::|g;
9e8c31cc 43
11fd7d05 44for 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