4 unless(grep /blib/, @INC) {
9 if ($Config::Config{'extensions'} !~ /\bSocket\b/) {
10 print "1..0 # Skip: Socket not built - IO.pm uses Socket";
18 require($ENV{PERL_CORE} ? "./test.pl" : "./t/test.pl");
26 local *XSLoader::load = sub {
30 # use_ok() calls import, which we do not want to do
32 ok( @load, 'IO should call XSLoader::load()' );
33 is( $load[0][0], 'IO', '... loading the IO library' );
34 is( $load[0][1], $IO::VERSION, '... with the current .pm version' );
37 my @default = map { "IO/$_.pm" } qw( Handle Seekable File Pipe Socket Dir );
38 delete @INC{ @default };
41 local $SIG{__WARN__} = sub { $warn = "@_" } ;
46 is( $warn, '', "... import default, should not warn");
53 is( $warn, '', "... import default, should not warn");
60 like( $warn, qr/^Parameterless "use IO" deprecated at/,
61 "... import default, should warn");
66 use warnings 'deprecated' ;
68 like( $warn, qr/^Parameterless "use IO" deprecated at/,
69 "... import default, should warn");
76 like( $warn, qr/^Parameterless "use IO" deprecated at/,
77 "... import default, should warn");
81 foreach my $default (@default)
83 ok( exists $INC{ $default }, "... import should default load $default" );
86 eval { IO->import( 'nothere' ) };
87 like( $@, qr/Can.t locate IO.nothere\.pm/, '... croaking on any error' );
89 my $fakedir = File::Spec->catdir( 'lib', 'IO' );
90 my $fakemod = File::Spec->catfile( $fakedir, 'fakemod.pm' );
93 if ( -d $fakedir or mkpath( $fakedir ))
95 if (open( OUT, ">$fakemod"))
97 (my $package = <<' END_HERE') =~ tr/\t//d;
100 sub import { die "Do not import!\n" }
119 skip("Could not write to disk", 2 ) unless $flag;
120 eval { IO->import( 'fakemod' ) };
121 ok( IO::fakemod::exists(), 'import() should import IO:: modules by name' );
122 is( $@, '', '... and should not call import() on imported modules' );
127 1 while unlink $fakemod;