1#!/usr/bin/perl -wT 2 3BEGIN { 4 if( $ENV{PERL_CORE} ) { 5 chdir 't'; 6 @INC = '../lib'; 7 } 8} 9 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" ); 39 40# Now try to load well known XS modules 41my $extensions = $Config{'extensions'}; 42$extensions =~ s|/|::|g; 43 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} 51 52