12 use Test::More tests => 18;
15 local $INC{'XSLoader.pm'} = 1;
16 local *XSLoader::load;
19 *XSLoader::load = sub {
23 # use_ok() calls import, which we do not want to do
25 ok( @load, 'IO should call XSLoader::load()' );
26 is( $load[0][0], 'IO', '... loading the IO library' );
27 is( $load[0][1], $IO::VERSION, '... with the current .pm version' );
30 my @default = map { "IO/$_.pm" } qw( Handle Seekable File Pipe Socket Dir );
31 delete @INC{ @default };
34 local $SIG{__WARN__} = sub { $warn = "@_" } ;
39 is( $warn, '', "... import default, should not warn");
46 is( $warn, '', "... import default, should not warn");
53 like( $warn, qr/^Parameterless "use IO" deprecated at/,
54 "... import default, should warn");
59 use warnings 'deprecated' ;
61 like( $warn, qr/^Parameterless "use IO" deprecated at/,
62 "... import default, should warn");
69 like( $warn, qr/^Parameterless "use IO" deprecated at/,
70 "... import default, should warn");
74 foreach my $default (@default)
76 ok( exists $INC{ $default }, "... import should default load $default" );
79 eval { IO->import( 'nothere' ) };
80 like( $@, qr/Can.t locate IO.nothere\.pm/, '... croaking on any error' );
82 my $fakedir = File::Spec->catdir( 'lib', 'IO' );
83 my $fakemod = File::Spec->catfile( $fakedir, 'fakemod.pm' );
86 if ( -d $fakedir or mkpath( $fakedir ))
88 if (open( OUT, ">$fakemod"))
90 (my $package = <<' END_HERE') =~ tr/\t//d;
93 sub import { die "Do not import!\n" }
112 skip("Could not write to disk", 2 ) unless $flag;
113 eval { IO->import( 'fakemod' ) };
114 ok( IO::fakemod::exists(), 'import() should import IO:: modules by name' );
115 is( $@, '', '... and should not call import() on imported modules' );
120 1 while unlink $fakemod;