4 if( $ENV{PERL_CORE} ) {
15 eval "use Test::More";
17 print "1..0 # Skip: Test::More not available\n";
18 die "Test::More not available\n";
22 foreach (qw/SDBM_File GDBM_File ODBM_File NDBM_File DB_File/) {
23 if ($Config{extensions} =~ /\b$_\b/) {
32 # ModuleName => q|code to check that it was loaded|,
33 'Cwd' => q| ::can_ok( 'Cwd' => 'fastcwd' ) |, # 5.7 ?
34 'File::Glob' => q| ::can_ok( 'File::Glob' => 'doglob' ) |, # 5.6
35 $db_file => q| ::can_ok( $db_file => 'TIEHASH' ) |, # 5.0
36 'Socket' => q| ::can_ok( 'Socket' => 'inet_aton' ) |, # 5.0
37 'Time::HiRes'=> q| ::can_ok( 'Time::HiRes' => 'usleep' ) |, # 5.7.3
40 plan tests => keys(%modules) * 4 + 5;
42 # Try to load the module
46 can_ok( 'XSLoader' => 'load' );
47 can_ok( 'XSLoader' => 'bootstrap_inherit' );
49 # Check error messages
50 eval { XSLoader::load() };
51 like( $@, '/^XSLoader::load\(\'Your::Module\', \$Your::Module::VERSION\)/',
52 "calling XSLoader::load() with no argument" );
54 eval q{ package Thwack; XSLoader::load('Thwack'); };
56 like( $@, q{/^Can't locate loadable object for module Thwack in @INC/},
57 "calling XSLoader::load() under a package with no XS part" );
60 like( $@, q{/^Can't load module Thwack, dynamic loading not available in this perl./},
61 "calling XSLoader::load() under a package with no XS part" );
64 # Now try to load well known XS modules
65 my $extensions = $Config{'extensions'};
66 $extensions =~ s|/|::|g;
68 for my $module (sort keys %modules) {
70 local $SIG{__WARN__} = sub { $warnings = $_[0] };
73 skip "$module not available", 4 if $extensions !~ /\b$module\b/;
75 eval qq{ package $module; XSLoader::load('$module', "qunckkk"); };
76 like( $@, "/^$module object version \\S+ does not match bootstrap parameter (?:qunckkk|0)/",
77 "calling XSLoader::load() with a XS module and an incorrect version" );
78 like( $warnings, "/^\$|^Version string 'qunckkk' contains invalid data; ignoring: 'qunckkk'/",
79 "in Perl 5.10, DynaLoader warns about the incorrect version string" );
81 eval qq{ package $module; XSLoader::load('$module'); };
82 is( $@, '', "XSLoader::load($module)");
84 eval qq{ package $module; $modules{$module}; };