summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/perl/lib/blib.t
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2002-10-27 22:15:15 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2002-10-27 22:15:15 +0000
commit74cfb115ac810480c0000dc742b20383c1578bac (patch)
tree316d96e5123617976f1637b143570c309a662045 /gnu/usr.bin/perl/lib/blib.t
parent453ade492b8e06c619009d6cd52a85cb04e8cf17 (diff)
stock perl 5.8.0 from CPAN
Diffstat (limited to 'gnu/usr.bin/perl/lib/blib.t')
-rw-r--r--gnu/usr.bin/perl/lib/blib.t77
1 files changed, 77 insertions, 0 deletions
diff --git a/gnu/usr.bin/perl/lib/blib.t b/gnu/usr.bin/perl/lib/blib.t
new file mode 100644
index 00000000000..b6df9e8d2b9
--- /dev/null
+++ b/gnu/usr.bin/perl/lib/blib.t
@@ -0,0 +1,77 @@
+#!./perl -Tw
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+use strict;
+use File::Spec;
+my($blib, $blib_arch, $blib_lib, @blib_dirs);
+
+sub _cleanup {
+ rmdir foreach reverse (@_);
+ unlink "stderr" unless $^O eq 'MacOS';
+}
+
+sub _mkdirs {
+ for my $dir (@_) {
+ next if -d $dir;
+ mkdir $dir or die "Can't mkdir $dir: $!" if ! -d $dir;
+ }
+}
+
+
+BEGIN {
+ if ($^O eq 'MacOS')
+ {
+ $MacPerl::Architecture = $MacPerl::Architecture; # shhhhh
+ $blib = ":blib:";
+ $blib_lib = ":blib:lib:";
+ $blib_arch = ":blib:lib:$MacPerl::Architecture:";
+ @blib_dirs = ($blib, $blib_lib, $blib_arch); # order
+ }
+ else
+ {
+ $blib = "blib";
+ $blib_arch = "blib/arch";
+ $blib_lib = "blib/lib";
+ @blib_dirs = ($blib, $blib_arch, $blib_lib);
+ }
+ _cleanup( @blib_dirs );
+}
+
+use Test::More tests => 7;
+
+eval 'use blib;';
+ok( $@ =~ /Cannot find blib/, 'Fails if blib directory not found' );
+
+_mkdirs( @blib_dirs );
+
+{
+ my $warnings = '';
+ local $SIG{__WARN__} = sub { $warnings = join '', @_ };
+ use_ok('blib');
+ is( $warnings, '', 'use blib is nice and quiet' );
+}
+
+is( @INC, 3, '@INC now has 3 elements' );
+is( $INC[2], '../lib', 'blib added to the front of @INC' );
+
+if ($^O eq 'VMS') {
+ # Unix syntax is accepted going in but it's not what comes out
+ # So we don't use catdir above
+ $blib_arch = 'blib.arch]';
+ $blib_lib = 'blib.lib]';
+}
+elsif ($^O ne 'MacOS')
+{
+ $blib_arch = File::Spec->catdir("blib","arch");
+ $blib_lib = File::Spec->catdir("blib","lib");
+}
+
+
+ok( grep(m|\Q$blib_lib\E$|, @INC[0,1]) == 1, " $blib_lib in \@INC");
+ok( grep(m|\Q$blib_arch\E$|, @INC[0,1]) == 1, " $blib_arch in \@INC");
+
+END { _cleanup( @blib_dirs ); }