Fix [perl #66970] Incorrect coderef in MODIFY_CODE_ATTRIBUTES
[p5sagit/p5-mst-13.2.git] / ext / List-Util / t / tainted.t
CommitLineData
f4a2945e 1#!./perl -T
2
3BEGIN {
1bfb5477 4 unless (-d 'blib') {
f4a2945e 5 chdir 't' if -d 't';
6 @INC = '../lib';
6b05f64e 7 require Config; import Config;
1bfb5477 8 keys %Config; # Silence warning
6b05f64e 9 if ($Config{extensions} !~ /\bList\/Util\b/) {
10 print "1..0 # Skip: List::Util was not built\n";
11 exit 0;
12 }
1bfb5477 13 }
9850bf21 14 elsif(!grep {/blib/} @INC) {
15 unshift(@INC, qw(./inc ./blib/arch ./blib/lib));
16 }
f4a2945e 17}
18
cf083cf9 19use Test::More tests => 4;
f4a2945e 20
cf083cf9 21use Scalar::Util qw(tainted);
f4a2945e 22
cf083cf9 23ok( !tainted(1), 'constant number');
f4a2945e 24
25my $var = 2;
26
cf083cf9 27ok( !tainted($var), 'known variable');
f4a2945e 28
4b12b7f5 29my $key = (keys %ENV)[0];
f4a2945e 30
cf083cf9 31ok( tainted($ENV{$key}), 'environment variable');
f4a2945e 32
cf083cf9 33$var = $ENV{$key};
34ok( tainted($var), 'copy of environment variable');