X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=tests%2Fformats%2Fdate-in.sh;h=67fe5799e4bf9fa57a79388e50bda31ec974a3b3;hb=bf3da7e3a72705f3e9d0d09ba29039928dc64687;hp=e5314a390e0ad8e6e977404a74bd8d83a3526f01;hpb=dea1f720db1da7dba1cf248660fc9e79d6b2d404;p=pspp-builds.git diff --git a/tests/formats/date-in.sh b/tests/formats/date-in.sh index e5314a39..67fe5799 100755 --- a/tests/formats/date-in.sh +++ b/tests/formats/date-in.sh @@ -38,6 +38,44 @@ pass() 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 program to generate PSPP syntax and data" cat > date-in.pl <<'EOF' #! /usr/bin/perl @@ -45,7 +83,7 @@ cat > date-in.pl <<'EOF' use strict; use warnings; -our $next = 1; +do 'my-rand.pl'; my @formats = (['date', 'd-m-y'], ['adate', 'm-d-y'], @@ -207,12 +245,6 @@ sub maybe_print_space { sub pick { return $_[int (my_rand ($#_ + 1))]; } - -sub my_rand { - my ($modulo) = @_; - $next = ($next * 1103515245 + 12345) % (2**32); - return int ($next / 65536) % $modulo; -} EOF if [ $? -ne 0 ] ; then no_result ; fi @@ -646,9 +678,8 @@ diff -u datetime.out - <