Commit | Line | Data |
---|---|---|
ea715489 | 1 | #!./perl -Tw |
2 | # Testing Cwd under taint mode. | |
3 | ||
4 | BEGIN { | |
5 | chdir 't' if -d 't'; | |
39f7733f | 6 | if ($ENV{PERL_CORE}) { |
7 | @INC = '../lib'; | |
8 | } | |
ea715489 | 9 | } |
39f7733f | 10 | use Cwd; |
ea715489 | 11 | |
3ee63918 | 12 | use strict; |
3ee63918 | 13 | use Test::More tests => 16; |
248785eb | 14 | use Scalar::Util qw/tainted/; |
ea715489 | 15 | |
3ee63918 | 16 | my @Functions = qw(getcwd cwd fastcwd fastgetcwd |
17 | abs_path fast_abs_path | |
18 | realpath fast_realpath | |
19 | ); | |
248785eb | 20 | |
3ee63918 | 21 | foreach my $func (@Functions) { |
22 | no strict 'refs'; | |
23 | my $cwd; | |
24 | eval { $cwd = &{'Cwd::'.$func} }; | |
a9939470 | 25 | is( $@, '', "$func() should not explode under taint mode" ); |
26 | ok( tainted($cwd), "its return value should be tainted" ); | |
3ee63918 | 27 | } |