[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pspp-cvs] pspp/tests/formats num-in.sh num-in.expected.gz
From: |
Ben Pfaff |
Subject: |
[Pspp-cvs] pspp/tests/formats num-in.sh num-in.expected.gz |
Date: |
Fri, 10 Aug 2007 03:17:56 +0000 |
CVSROOT: /cvsroot/pspp
Module name: pspp
Changes by: Ben Pfaff <blp> 07/08/10 03:17:56
Modified files:
tests/formats : num-in.sh num-in.expected.gz
Log message:
Fix first part of bug #18982. Thanks to John Darrington for finding
the problem and verifying the fix.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/tests/formats/num-in.sh?cvsroot=pspp&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/pspp/tests/formats/num-in.expected.gz?cvsroot=pspp&rev=1.2
Patches:
Index: num-in.sh
===================================================================
RCS file: /cvsroot/pspp/pspp/tests/formats/num-in.sh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- num-in.sh 22 Nov 2006 04:24:03 -0000 1.1
+++ num-in.sh 10 Aug 2007 03:17:55 -0000 1.2
@@ -38,6 +38,44 @@
cd $TEMPDIR
+activity="write PRNG fragment"
+cat > my-rand.pl <<'EOF'
+# This random number generator and the test for it below are drawn
+# from Park and Miller, "Random Number Generators: Good Ones are Hard
+# to Come By", Communications of the ACM 31:10 (October 1988). It is
+# documented to function properly on systems with a 46-bit or longer
+# real significand, which includes systems that have 64-bit IEEE reals
+# (with 53-bit significand). The test should catch any systems for
+# which this is not true, in any case.
+
+our ($seed) = 1;
+sub my_rand {
+ my ($modulo) = @_;
+ my ($a) = 16807;
+ my ($m) = 2147483647;
+ my ($tmp) = $a * $seed;
+ $seed = $tmp - $m * int ($tmp / $m);
+ return $seed % $modulo;
+}
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="write PRNG test program"
+cat > test-my-rand.pl <<'EOF'
+#! /usr/bin/perl
+use strict;
+use warnings;
+do 'my-rand.pl';
+my_rand (1) foreach 1...10000;
+our $seed;
+die $seed if $seed != 1043618065;
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="test PRNG"
+$PERL test-my-rand.pl
+if [ $? -ne 0 ] ; then no_result ; fi
+
activity="write Perl program"
cat > num-in.pl <<'EOF'
#! /usr/bin/perl
@@ -46,7 +84,7 @@
use strict;
use warnings;
-our $next = 0;
+do 'my-rand.pl';
for my $number (0, 1, .5, .015625, 123) {
my ($base_exp) = floor ($number ? log10 ($number) : 0);
@@ -135,12 +173,6 @@
sub pick {
return $_[int (my_rand ($#_ + 1))];
}
-
-sub my_rand {
- my ($modulo) = @_;
- $next = ($next * 1103515245 + 12345) % (2**32);
- return int ($next / 65536) % $modulo;
-}
EOF
activity="generate data"
Index: num-in.expected.gz
===================================================================
RCS file: /cvsroot/pspp/pspp/tests/formats/num-in.expected.gz,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
Binary files /tmp/cvsX1BvnB and /tmp/cvs6SoioF differ
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pspp-cvs] pspp/tests/formats num-in.sh num-in.expected.gz,
Ben Pfaff <=