6 unshift @INC, '../lib';
10 use Test::More tests => 13;
15 #set up files and directories
22 # lib.pm is documented to only work with Unix filepaths.
23 @lib_dir = qw(stuff moo);
24 $Lib_Dir = join "/", @lib_dir;
25 $Arch_Dir = join "/", @lib_dir, $Config{archname};
27 # create the auto/ directory and a module
28 $Auto_Dir = File::Spec->catdir(@lib_dir, $Config{archname},'auto');
29 $Module = File::Spec->catfile(@lib_dir, 'Yup.pm');
33 open(MOD, ">$Module") || DIE $!;
44 # cleanup the auto/ directory we created.
45 rmtree([$lib_dir[0]]);
52 BEGIN { use_ok('Yup') }
56 for ($Lib_Dir, $Arch_Dir) {
58 $_ .= ":" unless /:$/;
59 $_ = ":$_" unless /^:/; # we know this path is relative
62 is( $INC[1], $Lib_Dir, 'lib adding at end of @INC' );
63 print "# \@INC == @INC\n";
64 is( $INC[0], $Arch_Dir, ' auto/ dir in front of that' );
65 is( grep(/^\Q$Lib_Dir\E$/, @INC), 1, ' no duplicates' );
67 # Yes, %INC uses Unixy filepaths.
68 # Not on Mac OS, it doesn't ... it never has, at least.
69 my $path = join("/",$Lib_Dir, 'Yup.pm');
71 $path = $Lib_Dir . 'Yup.pm';
73 is( $INC{'Yup.pm'}, $path, '%INC set properly' );
75 is( eval { do 'Yup.pm' }, 42, 'do() works' );
76 ok( eval { require Yup; }, ' require()' );
77 ok( eval "use Yup; 1;", ' use()' );
80 is_deeply(\@OrigINC, \@lib::ORIG_INC, '@lib::ORIG_INC' );
85 unlike( do { eval 'use lib $Config{installsitelib};'; $@ || '' },
86 qr/::Config is read-only/, 'lib handles readonly stuff' );
89 is( grep(/stuff/, @INC), 0, 'no lib' );
90 ok( !do 'Yup.pm', ' do() effected' );