This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
shared hash keys and ++/--
[perl5.git] / lib / blib.t
1 #!./perl -Tw
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = '../lib';
6 }
7
8 use strict;
9
10 sub _cleanup {
11     rmdir foreach reverse qw(blib blib/arch blib/lib);
12     unlink "stderr";
13 }
14
15 sub _mkdirs {
16     for my $dir (@_) {
17         next if -d $dir;
18         mkdir $dir or die "Can't mkdir $dir: $!" if ! -d $dir;
19     }
20 }
21     
22
23 BEGIN { _cleanup }
24
25 use Test::More tests => 7;
26
27 eval 'use blib;';
28 ok( $@ =~ /Cannot find blib/, 'Fails if blib directory not found' );
29
30 _mkdirs(qw(blib blib/arch blib/lib));
31
32 {
33     my $warnings;
34     local $SIG{__WARN__} = sub { $warnings = join '', @_ };
35     use_ok('blib');
36     is( $warnings, '',  'use blib is niiiice and quiet' );
37 }
38
39 is( @INC, 3, '@INC now has 3 elements' );
40 is( $INC[2],    '../lib',       'blib added to the front of @INC' );
41
42 ok( grep(m|blib/lib$|, @INC[0,1])  == 1,     '  blib/lib in @INC');
43 ok( grep(m|blib/arch$|, @INC[0,1]) == 1,     '  blib/arch in @INC');
44
45 END { _cleanup(); }