8 if ($Config::Config{'extensions'} !~ /\bSocket\b/) {
9 print "1..0 # Skip: Socket not built - IO.pm uses Socket";
17 use Test::More tests => 18;
20 local $INC{'XSLoader.pm'} = 1;
21 local *XSLoader::load;
24 *XSLoader::load = sub {
28 # use_ok() calls import, which we do not want to do
30 ok( @load, 'IO should call XSLoader::load()' );
31 is( $load[0][0], 'IO', '... loading the IO library' );
32 is( $load[0][1], $IO::VERSION, '... with the current .pm version' );
35 my @default = map { "IO/$_.pm" } qw( Handle Seekable File Pipe Socket Dir );
36 delete @INC{ @default };
39 local $SIG{__WARN__} = sub { $warn = "@_" } ;
44 is( $warn, '', "... import default, should not warn");
51 is( $warn, '', "... import default, should not warn");
58 like( $warn, qr/^Parameterless "use IO" deprecated at/,
59 "... import default, should warn");
64 use warnings 'deprecated' ;
66 like( $warn, qr/^Parameterless "use IO" deprecated at/,
67 "... import default, should warn");
74 like( $warn, qr/^Parameterless "use IO" deprecated at/,
75 "... import default, should warn");
79 foreach my $default (@default)
81 ok( exists $INC{ $default }, "... import should default load $default" );
84 eval { IO->import( 'nothere' ) };
85 like( $@, qr/Can.t locate IO.nothere\.pm/, '... croaking on any error' );
87 my $fakedir = File::Spec->catdir( 'lib', 'IO' );
88 my $fakemod = File::Spec->catfile( $fakedir, 'fakemod.pm' );
91 if ( -d $fakedir or mkpath( $fakedir ))
93 if (open( OUT, ">$fakemod"))
95 (my $package = <<' END_HERE') =~ tr/\t//d;
98 sub import { die "Do not import!\n" }
117 skip("Could not write to disk", 2 ) unless $flag;
118 eval { IO->import( 'fakemod' ) };
119 ok( IO::fakemod::exists(), 'import() should import IO:: modules by name' );
120 is( $@, '', '... and should not call import() on imported modules' );
125 1 while unlink $fakemod;