summaryrefslogtreecommitdiff
path: root/t/op/taint.t
diff options
context:
space:
mode:
authorVincent Pit <perl@profvince.com>2011-06-27 10:09:00 +0200
committerVincent Pit <perl@profvince.com>2011-06-27 10:09:00 +0200
commitfa22d357d948ce8e179d9c7a461076497fc9681e (patch)
treea9f900a8558432b0367114b4221924dd142230b1 /t/op/taint.t
parentb1b5a4ae28189de4ce324e4b00842813774490c0 (diff)
downloadperl-fa22d357d948ce8e179d9c7a461076497fc9681e.tar.gz
Test taintedness of values returned by given/when
Diffstat (limited to 't/op/taint.t')
-rw-r--r--t/op/taint.t26
1 files changed, 25 insertions, 1 deletions
diff --git a/t/op/taint.t b/t/op/taint.t
index 9df6fee35c..0c9c2d07b7 100644
--- a/t/op/taint.t
+++ b/t/op/taint.t
@@ -17,7 +17,7 @@ BEGIN {
use strict;
use Config;
-plan tests => 774;
+plan tests => 780;
$| = 1;
@@ -2144,6 +2144,30 @@ end
is_tainted $dest, "ucfirst(tainted) taints its return value";
}
+{
+ # Taintedness of values returned from given()
+ use feature 'switch';
+
+ my @descriptions = ('when', 'given end', 'default');
+
+ for (qw<x y z>) {
+ my $letter = "$_$TAINT";
+
+ my $desc = "tainted value returned from " . shift(@descriptions);
+
+ my $res = do {
+ given ($_) {
+ when ('x') { $letter }
+ when ('y') { goto leavegiven }
+ default { $letter }
+ leavegiven: $letter
+ }
+ };
+ is $res, $letter, "$desc is correct";
+ is_tainted $res, "$desc stays tainted";
+ }
+}
+
# This may bomb out with the alarm signal so keep it last
SKIP: {
skip "No alarm()" unless $Config{d_alarm};