summaryrefslogtreecommitdiff
path: root/t/op/each.t
diff options
context:
space:
mode:
authorTom Phoenix <rootbeer@teleport.com>1996-12-29 17:46:21 -0800
committerChip Salzenberg <chip@atlantic.net>1997-01-01 08:59:00 +1200
commit3524d3b9766c150548bbd837b65d78ef993d647d (patch)
treea2d6506da30da1584d4c784254b5258564f0e0c6 /t/op/each.t
parentd5c001ddae568c5769b6a9eb70138c72d385cacb (diff)
downloadperl-3524d3b9766c150548bbd837b65d78ef993d647d.tar.gz
More tests
private-msgid: <Pine.GSO.3.95.961229170736.15213M-100000@solaris.teleport.co
Diffstat (limited to 't/op/each.t')
-rwxr-xr-xt/op/each.t41
1 files changed, 40 insertions, 1 deletions
diff --git a/t/op/each.t b/t/op/each.t
index 4106e54c50..b92dd1770c 100755
--- a/t/op/each.t
+++ b/t/op/each.t
@@ -2,7 +2,7 @@
# $RCSfile: each.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:47 $
-print "1..7\n";
+print "1..14\n";
$h{'abc'} = 'ABC';
$h{'def'} = 'DEF';
@@ -68,3 +68,42 @@ undef %h;
%h = (1,1);
$size = ((split('/',scalar %h))[1]);
if ($size == 8) {print "ok 7\n";} else {print "not ok 7\n";}
+
+# test scalar each
+%hash = 1..20;
+$total = 0;
+$total += $key while $key = each %hash;
+print "# Scalar each is bad.\nnot " unless $total == 100;
+print "ok 8\n";
+
+for (1..3) { @foo = each %hash }
+keys %hash;
+$total = 0;
+$total += $key while $key = each %hash;
+print "# Scalar keys isn't resetting the iterator.\nnot " if $total != 100;
+print "ok 9\n";
+
+for (1..3) { @foo = each %hash }
+$total = 0;
+$total += $key while $key = each %hash;
+print "# Iterator of each isn't being maintained.\nnot " if $total == 100;
+print "ok 10\n";
+
+for (1..3) { @foo = each %hash }
+values %hash;
+$total = 0;
+$total += $key while $key = each %hash;
+print "# Scalar values isn't resetting the iterator.\nnot " if $total != 100;
+print "ok 11\n";
+
+$size = (split('/', scalar %hash))[1];
+keys(%hash) = $size / 2;
+print "not " if $size != (split('/', scalar %hash))[1];
+print "ok 12\n";
+keys(%hash) = $size + 100;
+print "not " if $size == (split('/', scalar %hash))[1];
+print "ok 13\n";
+
+print "not " if keys(%hash) != 10;
+print "ok 14\n";
+