4 if( $ENV{PERL_CORE} ) {
14 eval "use Test::More";
16 print "1..0 # Skip: Test::More not available\n";
17 die "Test::More not available\n";
23 # ModuleName => q|code to check that it was loaded|,
24 'Cwd' => q| ::can_ok( 'Cwd' => 'fastcwd' ) |, # 5.7 ?
25 'File::Glob' => q| ::can_ok( 'File::Glob' => 'doglob' ) |, # 5.6
26 'SDBM_File' => q| ::can_ok( 'SDBM_File' => 'TIEHASH' ) |, # 5.0
27 'Socket' => q| ::can_ok( 'Socket' => 'inet_aton' ) |, # 5.0
28 'Time::HiRes'=> q| ::can_ok( 'Time::HiRes' => 'usleep' ) |, # 5.7.3
31 plan tests => keys(%modules) * 3 + 5;
33 # Try to load the module
37 can_ok( 'XSLoader' => 'load' );
38 can_ok( 'XSLoader' => 'bootstrap_inherit' );
40 # Check error messages
41 eval { XSLoader::load() };
42 like( $@, '/^XSLoader::load\(\'Your::Module\', \$Your::Module::VERSION\)/',
43 "calling XSLoader::load() with no argument" );
45 eval q{ package Thwack; XSLoader::load('Thwack'); };
46 like( $@, q{/^Can't locate loadable object for module Thwack in @INC/},
47 "calling XSLoader::load() under a package with no XS part" );
49 # Now try to load well known XS modules
50 my $extensions = $Config{'extensions'};
51 $extensions =~ s|/|::|g;
53 for my $module (sort keys %modules) {
55 skip "$module not available", 3 if $extensions !~ /\b$module\b/;
57 eval qq{ package $module; XSLoader::load('$module', "qunckkk"); };
58 like( $@, "/^$module object version \\S+ does not match bootstrap parameter (?:qunckkk|0\\.000)/",
59 "calling XSLoader::load() with a XS module and an incorrect version" );
61 eval qq{ package $module; XSLoader::load('$module'); };
62 is( $@, '', "XSLoader::load($module)");
64 eval qq{ package $module; $modules{$module}; };