In perl.git, the branch maint-5.10 has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/dcca518ffb52fbf647b67f1c7f9ae928b283a091?hp=d3e16e6877cb115e12847eee4681714908a20421>

- Log -----------------------------------------------------------------
commit dcca518ffb52fbf647b67f1c7f9ae928b283a091
Author: Rafael Garcia-Suarez <[email protected]>
Date:   Sun May 3 15:26:09 2009 +0200

    Add tests for last and next in when()
    
    (cherry-picked from commit 1ebfab3267504c83de6c437969845b8fbe1e7383)
-----------------------------------------------------------------------

Summary of changes:
 t/op/switch.t |   45 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 44 insertions(+), 1 deletions(-)

diff --git a/t/op/switch.t b/t/op/switch.t
index 848fad6..7e168d2 100644
--- a/t/op/switch.t
+++ b/t/op/switch.t
@@ -8,7 +8,7 @@ BEGIN {
 use strict;
 use warnings;
 
-use Test::More tests => 118;
+use Test::More tests => 122;
 
 # The behaviour of the feature pragma should be tested by lib/switch.t
 # using the tests in t/lib/switch/*. This file tests the behaviour of
@@ -901,6 +901,49 @@ SKIP: {
     skip "placeholder for tests not merged from f20dcd76e7", 7;
 }
 
+# Tests for last and next in when clauses
+my $letter;
+
+$letter = '';
+for ("a".."e") {
+    given ($_) {
+       $letter = $_;
+       when ("b") { last }
+    }
+    $letter = "z";
+}
+is($letter, "b", "last in when");
+
+$letter = '';
+LETTER1: for ("a".."e") {
+    given ($_) {
+       $letter = $_;
+       when ("b") { last LETTER1 }
+    }
+    $letter = "z";
+}
+is($letter, "b", "last LABEL in when");
+
+$letter = '';
+for ("a".."e") {
+    given ($_) {
+       when (/b|d/) { next }
+       $letter .= $_;
+    }
+    $letter .= ',';
+}
+is($letter, "a,c,e,", "next in when");
+
+$letter = '';
+LETTER2: for ("a".."e") {
+    given ($_) {
+       when (/b|d/) { next LETTER2 }
+       $letter .= $_;
+    }
+    $letter .= ',';
+}
+is($letter, "a,c,e,", "next LABEL in when");
+
 # Okay, that'll do for now. The intricacies of the smartmatch
 # semantics are tested in t/op/smartmatch.t
 __END__

--
Perl5 Master Repository

Reply via email to