Upgrade to PathTools 3.07
[p5sagit/p5-mst-13.2.git] / ext / Cwd / t / taint.t
1 #!./perl -Tw
2 # Testing Cwd under taint mode.
3
4 use strict;
5
6 BEGIN {
7     if ($ENV{PERL_CORE}) {
8         chdir 't';
9         @INC = '../lib';
10     }
11 }
12 use Cwd;
13 chdir 't';
14
15 use File::Spec;
16 use lib File::Spec->catdir('t', 'lib');
17 use Test::More tests => 17;
18
19 use Scalar::Util qw/tainted/;
20
21 my @Functions = qw(getcwd cwd fastcwd fastgetcwd
22                    abs_path fast_abs_path
23                    realpath fast_realpath
24                   );
25
26 foreach my $func (@Functions) {
27     no strict 'refs';
28     my $cwd;
29     eval { $cwd = &{'Cwd::'.$func} };
30     is( $@, '',         "$func() should not explode under taint mode" );
31     ok( tainted($cwd),  "its return value should be tainted" );
32 }
33
34 # Previous versions of Cwd tainted $^O
35 is !tainted($^O), 1, "\$^O should not be tainted";