In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/fa22d357d948ce8e179d9c7a461076497fc9681e?hp=b1b5a4ae28189de4ce324e4b00842813774490c0>

- Log -----------------------------------------------------------------
commit fa22d357d948ce8e179d9c7a461076497fc9681e
Author: Vincent Pit <[email protected]>
Date:   Mon Jun 27 10:09:00 2011 +0200

    Test taintedness of values returned by given/when
-----------------------------------------------------------------------

Summary of changes:
 t/op/switch.t |    3 ++-
 t/op/taint.t  |   26 +++++++++++++++++++++++++-
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/t/op/switch.t b/t/op/switch.t
index bdf087d..a286559 100644
--- a/t/op/switch.t
+++ b/t/op/switch.t
@@ -1362,5 +1362,6 @@ unreified_check(undef,"");
 }
 
 # Okay, that'll do for now. The intricacies of the smartmatch
-# semantics are tested in t/op/smartmatch.t
+# semantics are tested in t/op/smartmatch.t. Taintedness of
+# returned values is checked in t/op/taint.t.
 __END__
diff --git a/t/op/taint.t b/t/op/taint.t
index 9df6fee..0c9c2d0 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};

--
Perl5 Master Repository

Reply via email to