summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>1998-10-26 08:11:36 +0000
committerJarkko Hietaniemi <jhi@iki.fi>1998-10-26 08:11:36 +0000
commit596b5faa343a16c038c94a635344969cdc33e92b (patch)
treeeb159d14cbf351e13f634eea3dbea1d460ff49e5 /t
parent42e55ab11744b52a291540f8d6f74cf67d4e6093 (diff)
parentb86a2fa703d0daf651095b1947eb50e3b5cc41d9 (diff)
downloadperl-596b5faa343a16c038c94a635344969cdc33e92b.tar.gz
Integrate from mainperl.
p4raw-id: //depot/cfgperl@2088
Diffstat (limited to 't')
-rwxr-xr-xt/cmd/while.t21
-rwxr-xr-xt/op/oct.t5
-rwxr-xr-xt/op/rand.t15
-rwxr-xr-xt/op/tie.t13
4 files changed, 48 insertions, 6 deletions
diff --git a/t/cmd/while.t b/t/cmd/while.t
index c6e464d444..392c13779f 100755
--- a/t/cmd/while.t
+++ b/t/cmd/while.t
@@ -2,7 +2,7 @@
# $RCSfile: while.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:15 $
-print "1..10\n";
+print "1..15\n";
open (tmp,'>Cmd_while.tmp') || die "Can't create Cmd_while.tmp.";
print tmp "tvi925\n";
@@ -109,3 +109,22 @@ $i = 9;
$i++;
}
print "ok $i\n";
+
+# Check curpm is reset when jumping out of a scope
+'abc' =~ /b/;
+WHILE:
+while (1) {
+ $i++;
+ print "#$`,$&,$',\nnot " unless $` . $& . $' eq "abc";
+ print "ok $i\n";
+ { # Localize changes to $` and friends
+ 'end' =~ /end/;
+ redo WHILE if $i == 11;
+ next WHILE if $i == 12;
+ # 13 do a normal loop
+ last WHILE if $i == 14;
+ }
+}
+$i++;
+print "not " unless $` . $& . $' eq "abc";
+print "ok $i\n";
diff --git a/t/op/oct.t b/t/op/oct.t
index 24b5c4309d..66230898ab 100755
--- a/t/op/oct.t
+++ b/t/op/oct.t
@@ -1,8 +1,6 @@
#!./perl
-# $RCSfile: oct.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:08 $
-
-print "1..8\n";
+print "1..9\n";
print +(oct('01234') == 01234) ? "ok" : "not ok", " 1\n";
print +(oct('0x1234') == 0x1234) ? "ok" : "not ok", " 2\n";
@@ -12,3 +10,4 @@ print +(oct('x80000000') == 0x80000000) ? "ok" : "not ok", " 5\n";
print +(hex('80000000') == 0x80000000) ? "ok" : "not ok", " 6\n";
print +(oct('1234') == 668) ? "ok" : "not ok", " 7\n";
print +(hex('1234') == 4660) ? "ok" : "not ok", " 8\n";
+print +(hex('0x1234') == 0x1234) ? "ok" : "not ok", " 9\n";
diff --git a/t/op/rand.t b/t/op/rand.t
index a68559ff79..2f02d344fc 100755
--- a/t/op/rand.t
+++ b/t/op/rand.t
@@ -52,6 +52,17 @@ sub bits ($) {
$max = $min = rand(1);
for (1..$reps) {
my $n = rand(1);
+ if ($n < 0.0 or $n >= 1.0) {
+ print <<EOM;
+# WHOA THERE! \$Config{drand01} is set to '$Config{drand01}',
+# but that apparently produces values < 0.0 or >= 1.0.
+# Make sure \$Config{drand01} is a valid expression in the
+# C-language, and produces values in the range [0.0,1.0).
+#
+# I give up.
+EOM
+ exit;
+ }
$sum += $n;
$bits += bits($n * 256); # Don't be greedy; 8 is enough
# It's too many if randbits is less than 8!
@@ -75,7 +86,7 @@ sub bits ($) {
# wrong value is that Config.pm is incorrect.)
#
if ($max <= 0 or $max >= (2 ** $randbits)) {# Just in case...
- print "not ok 1\n";
+ print "# max=[$max] min=[$min]\nnot ok 1\n";
print "# This perl was compiled with randbits=$randbits\n";
print "# which is _way_ off. Or maybe your system rand is broken,\n";
print "# or your C compiler can't multiply, or maybe Martians\n";
@@ -91,7 +102,7 @@ sub bits ($) {
$off = int($off) + ($off > 0); # Next more positive int
if ($off) {
$shouldbe = $Config{randbits} + $off;
- print "not ok 1\n";
+ print "# max=[$max] min=[$min]\nnot ok 1\n";
print "# This perl was compiled with randbits=$randbits on $^O.\n";
print "# Consider using randbits=$shouldbe instead.\n";
# And skip the remaining tests; they would be pointless now.
diff --git a/t/op/tie.t b/t/op/tie.t
index f1b12d6d81..451dee07b3 100755
--- a/t/op/tie.t
+++ b/t/op/tie.t
@@ -153,3 +153,16 @@ $C = $B = tied %H ;
}
untie %H;
EXPECT
+########
+
+# verify no leak when underlying object is selfsame tied variable
+my ($a, $b);
+sub Self::TIEHASH { bless $_[1], $_[0] }
+sub Self::DESTROY { $b = $_[0] + 0; }
+{
+ my %b5;
+ $a = \%b5 + 0;
+ tie %b5, 'Self', \%b5;
+}
+die unless $a == $b;
+EXPECT