Fix bug #24383, where hashes with the :unique attribute weren't
[p5sagit/p5-mst-13.2.git] / t / cmd / for.t
old mode 100644 (file)
new mode 100755 (executable)
index 16745b5..3a4bc9b
@@ -1,8 +1,6 @@
 #!./perl
 
-# $Header: for.t,v 4.0 91/03/20 01:49:26 lwall Locked $
-
-print "1..7\n";
+print "1..13\n";
 
 for ($i = 0; $i <= 10; $i++) {
     $x[$i] = $i;
@@ -47,3 +45,34 @@ if ($foo eq '3210abcde') {print "ok 5\n";} else {print "not ok 5 $foo\n";}
 foreach $foo (("ok 6\n","ok 7\n")) {
        print $foo;
 }
+
+sub foo {
+    for $i (1..5) {
+       return $i if $_[0] == $i;
+    }
+}
+
+print foo(1) == 1 ? "ok" : "not ok", " 8\n";
+print foo(2) == 2 ? "ok" : "not ok", " 9\n";
+print foo(5) == 5 ? "ok" : "not ok", " 10\n";
+
+sub bar {
+    return (1, 2, 4);
+}
+
+$a = 0;
+foreach $b (bar()) {
+    $a += $b;
+}
+print $a == 7 ? "ok" : "not ok", " 11\n";
+
+$loop_count = 0;
+for ("-3" .. "0") {
+    $loop_count++;
+}
+print $loop_count == 4 ? "ok" : "not ok", " 12\n";
+
+# modifying arrays in loops is a no-no
+@a = (3,4);
+eval { @a = () for (1,2,@a) };
+print $@ =~ /Use of freed value in iteration/ ? "ok" : "not ok", " 13\n";