This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Revert #19957 as requested by Rafael.
[perl5.git] / ext / List / Util / t / tainted.t
CommitLineData
f4a2945e
JH
1#!./perl -T
2
3BEGIN {
1bfb5477 4 unless (-d 'blib') {
f4a2945e
JH
5 chdir 't' if -d 't';
6 @INC = '../lib';
6b05f64e 7 require Config; import Config;
1bfb5477 8 keys %Config; # Silence warning
6b05f64e
PP
9 if ($Config{extensions} !~ /\bList\/Util\b/) {
10 print "1..0 # Skip: List::Util was not built\n";
11 exit 0;
12 }
1bfb5477 13 }
f4a2945e
JH
14}
15
16use lib qw(blib/lib blib/arch);
17use Scalar::Util qw(tainted);
18use Config;
19
1bfb5477 20print "1..4\n";
f4a2945e
JH
21
22print "not " if tainted(1);
23print "ok 1\n";
24
25my $var = 2;
26
27print "not " if tainted($var);
28print "ok 2\n";
29
4b12b7f5 30my $key = (keys %ENV)[0];
f4a2945e
JH
31
32$var = $ENV{$key};
33
34print "not " unless tainted($var);
4b12b7f5 35print "ok 3\n";
f4a2945e
JH
36
37print "not " unless tainted($ENV{$key});
4b12b7f5 38print "ok 4\n";