summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2000-12-15 15:11:05 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2000-12-15 15:11:05 +0000
commit98a29390254d3cb423096b6282689bfe2a7e6a13 (patch)
tree7bef01eb07750fb8e9686429e95216a0ca3281c5 /t
parentf7bbb42a8a35cccf48af0f4db3b373ffcb7e1ac5 (diff)
downloadperl-98a29390254d3cb423096b6282689bfe2a7e6a13.tar.gz
This seems to be a stage sane and stable enough to checkin.
(it basically is 8102..8118+8122 but no 8120, 8121, 8123, 8124) p4raw-id: //depot/perl@8125
Diffstat (limited to 't')
-rw-r--r--t/lib/peek.t26
-rwxr-xr-xt/op/cmp.t176
-rwxr-xr-xt/op/numconvert.t24
3 files changed, 32 insertions, 194 deletions
diff --git a/t/lib/peek.t b/t/lib/peek.t
index 288d3bdf6d..a90574f744 100644
--- a/t/lib/peek.t
+++ b/t/lib/peek.t
@@ -88,10 +88,10 @@ do_test( 5,
do_test( 6,
$c + $d,
-'SV = IV\\($ADDR\\) at $ADDR
+'SV = NV\\($ADDR\\) at $ADDR
REFCNT = 1
- FLAGS = \\(PADTMP,IOK,pIOK\\)
- IV = 456');
+ FLAGS = \\(PADTMP,NOK,pNOK\\)
+ NV = 456');
($d = "789") += 0.1;
@@ -110,8 +110,8 @@ do_test( 8,
0xabcd,
'SV = IV\\($ADDR\\) at $ADDR
REFCNT = 1
- FLAGS = \\(.*IOK,READONLY,pIOK\\)
- IV = 43981');
+ FLAGS = \\(.*IOK,READONLY,pIOK,IsUV\\)
+ UV = 43981');
do_test( 9,
undef,
@@ -154,10 +154,12 @@ do_test(11,
FLAGS = \\(IOK,pIOK\\)
IV = 123
Elt No. 1
- SV = IV\\($ADDR\\) at $ADDR
+ SV = PVNV\\($ADDR\\) at $ADDR
REFCNT = 1
- FLAGS = \\(IOK,pIOK\\)
- IV = 456');
+ FLAGS = \\(IOK,NOK,pIOK,pNOK\\)
+ IV = 456
+ NV = 456
+ PV = 0');
do_test(12,
{$b=>$c},
@@ -178,10 +180,12 @@ do_test(12,
RITER = -1
EITER = 0x0
Elt "123" HASH = $ADDR
- SV = IV\\($ADDR\\) at $ADDR
+ SV = PVNV\\($ADDR\\) at $ADDR
REFCNT = 1
- FLAGS = \\(IOK,pIOK\\)
- IV = 456');
+ FLAGS = \\(IOK,NOK,pIOK,pNOK\\)
+ IV = 456
+ NV = 456
+ PV = 0');
do_test(13,
sub(){@_},
diff --git a/t/op/cmp.t b/t/op/cmp.t
index ffd34c62dd..4a7e68d448 100755
--- a/t/op/cmp.t
+++ b/t/op/cmp.t
@@ -1,185 +1,35 @@
#!./perl
-BEGIN {
- chdir 't' if -d 't';
- @INC = '../lib';
-}
-
-# 2s complement assumption. Won't break test, just makes the internals of
-# the SVs less interesting if were not on 2s complement system.
-my $uv_max = ~0;
-my $uv_maxm1 = ~0 ^ 1;
-my $uv_big = $uv_max;
-$uv_big = ($uv_big - 20000) | 1;
-my ($iv0, $iv1, $ivm1, $iv_min, $iv_max, $iv_big, $iv_small);
-$iv_max = $uv_max; # Do copy, *then* divide
-$iv_max /= 2;
-$iv_min = $iv_max;
-{
- use integer;
- $iv0 = 2 - 2;
- $iv1 = 3 - 2;
- $ivm1 = 2 - 3;
- $iv_max -= 1;
- $iv_min += 0;
- $iv_big = $iv_max - 3;
- $iv_small = $iv_min + 2;
-}
-my $uv_bigi = $iv_big;
-$uv_bigi |= 0x0;
-
-# Seems one needs to perform the maths on 'Inf' to get the NV correctly primed.
-@FOO = ('s', 'N/A', 'a', 'NaN', -1, undef, 0, 1, 3.14, 1e37, 0.632120558, -.5,
- 'Inf'+1, '-Inf'-1, 0x0, 0x1, 0x5, 0xFFFFFFFF, $uv_max, $uv_maxm1,
- $uv_big, $uv_bigi, $iv0, $iv1, $ivm1, $iv_min, $iv_max, $iv_big,
- $iv_small);
+@FOO = ('s', 'N/A', 'a', 'NaN', -1, undef, 0, 1);
-$expect = 6 * ($#FOO+2) * ($#FOO+1);
+$expect = ($#FOO+2) * ($#FOO+1);
print "1..$expect\n";
my $ok = 0;
for my $i (0..$#FOO) {
for my $j ($i..$#FOO) {
$ok++;
- # Comparison routines may convert these internally, which would change
- # what is used to determine the comparison on later runs. Hence copy
- my ($i1, $i2, $i3, $i4, $i5, $i6, $i7, $i8, $i9, $i10,
- $i11, $i12, $i13, $i14, $i15) =
- ($FOO[$i], $FOO[$i], $FOO[$i], $FOO[$i], $FOO[$i],
- $FOO[$i], $FOO[$i], $FOO[$i], $FOO[$i], $FOO[$i],
- $FOO[$i], $FOO[$i], $FOO[$i], $FOO[$i], $FOO[$i]);
- my ($j1, $j2, $j3, $j4, $j5, $j6, $j7, $j8, $j9, $j10,
- $j11, $j12, $j13, $j14, $j15) =
- ($FOO[$j], $FOO[$j], $FOO[$j], $FOO[$j], $FOO[$j],
- $FOO[$j], $FOO[$j], $FOO[$j], $FOO[$j], $FOO[$j],
- $FOO[$j], $FOO[$j], $FOO[$j], $FOO[$j], $FOO[$j]);
- my $cmp = $i1 <=> $j1;
- if (!defined($cmp) ? !($i2 < $j2)
- : ($cmp == -1 && $i2 < $j2 ||
- $cmp == 0 && !($i2 < $j2) ||
- $cmp == 1 && !($i2 < $j2)))
- {
- print "ok $ok\n";
- }
- else {
- print "not ok $ok # ($i3 <=> $j3) gives: '$cmp' \$i=$i \$j=$j, < disagrees\n";
- }
- $ok++;
- if (!defined($cmp) ? !($i4 == $j4)
- : ($cmp == -1 && !($i4 == $j4) ||
- $cmp == 0 && $i4 == $j4 ||
- $cmp == 1 && !($i4 == $j4)))
- {
- print "ok $ok\n";
- }
- else {
- print "not ok $ok # ($i3 <=> $j3) gives: '$cmp' \$i=$i \$j=$j, == disagrees\n";
- }
- $ok++;
- if (!defined($cmp) ? !($i5 > $j5)
- : ($cmp == -1 && !($i5 > $j5) ||
- $cmp == 0 && !($i5 > $j5) ||
- $cmp == 1 && ($i5 > $j5)))
- {
- print "ok $ok\n";
- }
- else {
- print "not ok $ok # ($i3 <=> $j3) gives: '$cmp' \$i=$i \$j=$j, > disagrees\n";
- }
- $ok++;
- if (!defined($cmp) ? !($i6 >= $j6)
- : ($cmp == -1 && !($i6 >= $j6) ||
- $cmp == 0 && $i6 >= $j6 ||
- $cmp == 1 && $i6 >= $j6))
- {
- print "ok $ok\n";
- }
- else {
- print "not ok $ok # ($i3 <=> $j3) gives: '$cmp' \$i=$i \$j=$j, >= disagrees\n";
- }
- $ok++;
- # OK, so the docs are wrong it seems. NaN != NaN
- if (!defined($cmp) ? ($i7 != $j7)
- : ($cmp == -1 && $i7 != $j7 ||
- $cmp == 0 && !($i7 != $j7) ||
- $cmp == 1 && $i7 != $j7))
- {
- print "ok $ok\n";
- }
- else {
- print "not ok $ok # ($i3 <=> $j3) gives: '$cmp' \$i=$i \$j=$j, != disagrees\n";
- }
- $ok++;
- if (!defined($cmp) ? !($i8 <= $j8)
- : ($cmp == -1 && $i8 <= $j8 ||
- $cmp == 0 && $i8 <= $j8 ||
- $cmp == 1 && !($i8 <= $j8)))
- {
- print "ok $ok\n";
- }
- else {
- print "not ok $ok # ($i3 <=> $j3) gives: '$cmp' \$i=$i \$j=$j, <= disagrees\n";
- }
- $ok++;
- $cmp = $i9 cmp $j9;
- if ($cmp == -1 && $i10 lt $j10 ||
- $cmp == 0 && !($i10 lt $j10) ||
- $cmp == 1 && !($i10 lt $j10))
- {
- print "ok $ok\n";
- }
- else {
- print "not ok $ok # ($i3 cmp $j3) gives '$cmp' \$i=$i \$j=$j, lt disagrees\n";
- }
- $ok++;
- if ($cmp == -1 && !($i11 eq $j11) ||
- $cmp == 0 && ($i11 eq $j11) ||
- $cmp == 1 && !($i11 eq $j11))
- {
- print "ok $ok\n";
- }
- else {
- print "not ok $ok # ($i3 cmp $j3) gives '$cmp' \$i=$i \$j=$j, eq disagrees\n";
- }
- $ok++;
- if ($cmp == -1 && !($i12 gt $j12) ||
- $cmp == 0 && !($i12 gt $j12) ||
- $cmp == 1 && ($i12 gt $j12))
- {
- print "ok $ok\n";
- }
- else {
- print "not ok $ok # ($i3 cmp $j3) gives '$cmp' \$i=$i \$j=$j, gt disagrees\n";
- }
- $ok++;
- if ($cmp == -1 && $i13 le $j13 ||
- $cmp == 0 && ($i13 le $j13) ||
- $cmp == 1 && !($i13 le $j13))
- {
- print "ok $ok\n";
- }
- else {
- print "not ok $ok # ($i3 cmp $j3) gives '$cmp' \$i=$i \$j=$j, le disagrees\n";
- }
- $ok++;
- if ($cmp == -1 && ($i14 ne $j14) ||
- $cmp == 0 && !($i14 ne $j14) ||
- $cmp == 1 && ($i14 ne $j14))
+ my $cmp = $FOO[$i] <=> $FOO[$j];
+ if (!defined($cmp) ||
+ $cmp == -1 && $FOO[$i] < $FOO[$j] ||
+ $cmp == 0 && $FOO[$i] == $FOO[$j] ||
+ $cmp == 1 && $FOO[$i] > $FOO[$j])
{
print "ok $ok\n";
}
else {
- print "not ok $ok # ($i3 cmp $j3) gives '$cmp' \$i=$i \$j=$j, ne disagrees\n";
+ print "not ok $ok ($FOO[$i] <=> $FOO[$j]) gives: '$cmp'\n";
}
$ok++;
- if ($cmp == -1 && !($i15 ge $j15) ||
- $cmp == 0 && ($i15 ge $j15) ||
- $cmp == 1 && ($i15 ge $j15))
+ $cmp = $FOO[$i] cmp $FOO[$j];
+ if ($cmp == -1 && $FOO[$i] lt $FOO[$j] ||
+ $cmp == 0 && $FOO[$i] eq $FOO[$j] ||
+ $cmp == 1 && $FOO[$i] gt $FOO[$j])
{
print "ok $ok\n";
}
else {
- print "not ok $ok # ($i3 cmp $j3) gives '$cmp' \$i=$i \$j=$j, ge disagrees\n";
+ print "not ok $ok ($FOO[$i] cmp $FOO[$j]) gives '$cmp'\n";
}
}
}
diff --git a/t/op/numconvert.t b/t/op/numconvert.t
index 3db280bbfd..f3c9867a91 100755
--- a/t/op/numconvert.t
+++ b/t/op/numconvert.t
@@ -85,15 +85,8 @@ my @list = (1, $yet_smaller_than_iv, $smaller_than_iv, $max_iv, $max_iv + 1,
unshift @list, (reverse map -$_, @list), 0; # 15 elts
@list = map "$_", @list; # Normalize
-print "# @list\n";
+# print "@list\n";
-# need to special case ++ for max_uv, as ++ "magic" on a string gives
-# another string, whereas ++ magic on a string used as a number gives
-# a number. Not a problem when NV preserves UV, but if it doesn't then
-# stringification of the latter gives something in e notation.
-
-my $max_uv_pp = "$max_uv"; $max_uv_pp++;
-my $max_uv_p1 = "$max_uv"; $max_uv_p1+=0; $max_uv_p1++;
my @opnames = split //, "-+UINPuinp";
@@ -185,18 +178,9 @@ for my $num_chain (1..$max_chain) {
}
push @ans, $inpt;
}
- if ($ans[0] ne $ans[1]) {
- print "# '$ans[0]' ne '$ans[1]',\t$num\t=> @opnames[$first,@{$curops[0]},$last] vs @opnames[$first,@{$curops[1]},$last]\n";
- # XXX ought to check that "+" was in the list of opnames
- if ((($ans[0] eq $max_uv_pp) and ($ans[1] eq $max_uv_p1))
- or (($ans[1] eq $max_uv_pp) and ($ans[0] eq $max_uv_p1))) {
- # string ++ versus numeric ++. Tolerate this little
- # bit of insanity
- print "# ok, as string ++ of max_uv is \"$max_uv_pp\", numeric is $max_uv_p1\n"
- } else {
- $nok++,
- }
- }
+ $nok++,
+ print "# '$ans[0]' ne '$ans[1]',\t$num\t=> @opnames[$first,@{$curops[0]},$last] vs @opnames[$first,@{$curops[1]},$last]\n"
+ if $ans[0] ne $ans[1];
}
print "not " if $nok;
print "ok $test\n";