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