summaryrefslogtreecommitdiff
path: root/t/op
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>2002-03-17 17:38:44 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>2002-03-17 17:38:44 +0000
commitbfc6ee55d1516cdf7661b066de0cdfa18993bee6 (patch)
treed0dc3d17bf3a36954c3c2639c972a2f4017531ee /t/op
parente417e6d439d9f03a0c6005bc25522b721fd5ec92 (diff)
parent6e602e293de56675e46a43a5c73830035f39277b (diff)
downloadperl-bfc6ee55d1516cdf7661b066de0cdfa18993bee6.tar.gz
Integrate mainline
p4raw-id: //depot/perlio@15271
Diffstat (limited to 't/op')
-rwxr-xr-xt/op/pat.t9
-rw-r--r--t/op/pow.t46
2 files changed, 54 insertions, 1 deletions
diff --git a/t/op/pat.t b/t/op/pat.t
index 4fb3d45e5e..67ca7659ad 100755
--- a/t/op/pat.t
+++ b/t/op/pat.t
@@ -6,7 +6,7 @@
$| = 1;
-print "1..860\n";
+print "1..861\n";
BEGIN {
chdir 't' if -d 't';
@@ -2706,3 +2706,10 @@ print "# some Unicode properties\n";
$i++;
}
}
+
+{
+ print "# SEGV in s/// and UTF-8\n";
+ $s = "s#\x{100}" x 4;
+ $s =~ s/[^\w]/ /g;
+ print $s eq "s \x{100}" x 4 ? "ok 861\n" : "not ok 861\n";
+}
diff --git a/t/op/pow.t b/t/op/pow.t
new file mode 100644
index 0000000000..2e1d29fcb0
--- /dev/null
+++ b/t/op/pow.t
@@ -0,0 +1,46 @@
+#!./perl -w
+# Now they'll be wanting biff! and zap! tests too.
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+ require './test.pl';
+}
+
+# This calcualtion ought to be within 0.001 of the right answer.
+my $bits_in_uv = int (0.001 + log (~0+1) / log 2);
+
+# 3**30 < 2**48, don't trust things outside that range on a Cray
+# Likewise other 3 should not overflow 48 bits if I did my sums right.
+my @pow = ([3,30,1e-14], [4,32,0], [5,20,1e-14], [2.5, 10,,1e-14], [-2, 69,0]);
+my $tests;
+$tests += $_->[1] foreach @pow;
+
+plan tests => 1 + $bits_in_uv + $tests;
+
+# Ought to be 32, 64, 36 or something like that.
+
+my $remainder = $bits_in_uv & 3;
+
+cmp_ok ($remainder, '==', 0, 'Sanity check bits in UV calculation')
+ or printf "# ~0 is %d (0x%d) which gives $bits_in_uv bits\n", ~0, ~0;
+
+# These are a lot of brute force tests to see how accurate $m ** $n is.
+# Unfortunately rather a lot of perl programs expect 2 ** $n to be integer
+# perfect, forgetting that it's a call to floating point pow() which never
+# claims to deliver perfection.
+foreach my $n (0..$bits_in_uv - 1) {
+ my $exp = 2 ** $n;
+ my $int = 1 << $n;
+ cmp_ok ($exp, '==', $int, "2 ** $n vs 1 << $n");
+}
+
+foreach my $pow (@pow) {
+ my ($base, $max, $range) = @$pow;
+ my $fp = 1;
+ foreach my $n (0..$max-1) {
+ my $exp = $base ** $n;
+ within ($exp, $fp, $range, "$base ** $n [$exp] vs $base * $base * ...");
+ $fp *= $base;
+ }
+}