Fix bug #18982. Thanks to John Darrington for investigation,
[pspp-builds.git] / tests / formats / date-in.sh
index e5314a390e0ad8e6e977404a74bd8d83a3526f01..67fe5799e4bf9fa57a79388e50bda31ec974a3b3 100755 (executable)
@@ -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 - <<EOF
     2071958400.00
     2071958400.00
     2071958400.00
-    3083547000.00
-    3083547000.00
-    3083547000.00
+    3083512200.00
+    3083512200.00
     3083512200.00
     3083512200.00
     3083547000.00
@@ -656,47 +687,47 @@ diff -u datetime.out - <<EOF
     3083547000.00
     3083547000.00
     3083512200.00
-    4221545340.00
-    4221635460.00
-    4221635460.00
-    4221635460.00
+    3083547000.00
     4221635460.00
     4221635460.00
+    4221545340.00
     4221635460.00
+    4221545340.00
     4221635460.00
     4221545340.00
+    4221635460.00
     4221545340.00
+    4221635460.00
     5859607620.00
     5859607620.00
-    5859515580.00
     5859607620.00
-    5859515580.00
     5859607620.00
+    5859515580.00
     5859607620.00
     5859607620.00
+    5859515580.00
     5859607620.00
     5859607620.00
     7472644440.00
     7472654760.00
-    7472644440.00
-    7472654760.00
-    7472654760.00
     7472654760.00
     7472654760.00
+    7472644440.00
     7472654760.00
     7472644440.00
+    7472644440.00
+    7472654760.00
     7472654760.00
-    8092666920.00
-    8092817880.00
     8092817880.00
     8092817880.00
     8092817880.00
     8092817880.00
     8092666920.00
     8092817880.00
-    8092666920.00
     8092817880.00
-   10114356960.00
+    8092817880.00
+    8092817880.00
+    8092817880.00
    10114356960.00
    10114302240.00
    10114302240.00
@@ -704,128 +735,129 @@ diff -u datetime.out - <<EOF
    10114356960.00
    10114356960.00
    10114356960.00
-   10114302240.00
    10114356960.00
+   10114356960.00
+   10114302240.00
+   10945873020.00
+   10945873020.00
+   10945873020.00
    10945986180.00
+   10945873020.00
    10945986180.00
+   10945873020.00
    10945986180.00
    10945986180.00
-   10945986180.00
-   10945986180.00
-   10945986180.00
-   10945986180.00
-   10945873020.00
    10945873020.00
-   11327628900.00
-   11327628900.00
    11327660700.00
+   11327628900.00
    11327660700.00
    11327660700.00
    11327628900.00
+   11327628900.00
    11327660700.00
    11327660700.00
    11327660700.00
    11327660700.00
    11376658140.00
-   11376609060.00
    11376658140.00
-   11376609060.00
    11376658140.00
    11376658140.00
-   11376609060.00
+   11376658140.00
+   11376658140.00
    11376609060.00
    11376658140.00
    11376658140.00
-   11391397380.00
+   11376609060.00
+   11391418620.00
    11391418620.00
-   11391397380.00
-   11391397380.00
    11391418620.00
    11391397380.00
    11391418620.00
    11391418620.00
    11391397380.00
+   11391418620.00
+   11391397380.00
    11391397380.00
    12920229900.00
    12920109300.00
    12920109300.00
+   12920109300.00
    12920229900.00
    12920229900.00
-   12920109300.00
    12920229900.00
    12920229900.00
    12920109300.00
-   12920229900.00
-   13044663000.00
+   12920109300.00
    13044508200.00
    13044663000.00
    13044663000.00
-   13044663000.00
    13044508200.00
    13044508200.00
    13044663000.00
    13044663000.00
    13044508200.00
+   13044663000.00
+   13044663000.00
+   11327628900.00
    11327660700.00
    11327660700.00
+   11327628900.00
    11327660700.00
    11327660700.00
-   11327660700.00
-   11327628900.00
    11327628900.00
    11327660700.00
    11327628900.00
-   11327660700.00
-   11376609060.00
+   11327628900.00
    11376658140.00
    11376658140.00
    11376658140.00
-   11376609060.00
-   11376609060.00
    11376658140.00
    11376658140.00
+   11376609060.00
+   11376609060.00
    11376658140.00
+   11376609060.00
    11376658140.00
    11391418620.00
-   11391418620.00
    11391397380.00
    11391418620.00
-   11391418620.00
-   11391418620.00
+   11391397380.00
+   11391397380.00
+   11391397380.00
    11391418620.00
    11391418620.00
    11391418620.00
    11391397380.00
-   12920109300.00
    12920229900.00
    12920229900.00
-   12920109300.00
-   12920109300.00
    12920229900.00
-   12920109300.00
    12920229900.00
    12920229900.00
+   12920229900.00
+   12920109300.00
+   12920229900.00
    12920109300.00
+   12920229900.00
    13044508200.00
    13044663000.00
+   13044508200.00
+   13044663000.00
+   13044663000.00
    13044663000.00
    13044663000.00
    13044663000.00
-   13044508200.00
-   13044508200.00
    13044663000.00
    13044508200.00
-   13044508200.00
-   14392420200.00
-   14392420200.00
    14392420200.00
    14392420200.00
    14392258200.00
-   14392420200.00
    14392258200.00
+   14392420200.00
    14392258200.00
    14392258200.00
    14392420200.00
+   14392420200.00
+   14392420200.00
    16149635760.00
    16149621840.00
    16149635760.00
@@ -833,9 +865,9 @@ diff -u datetime.out - <<EOF
    16149635760.00
    16149635760.00
    16149635760.00
-   16149635760.00
-   16149635760.00
    16149621840.00
+   16149621840.00
+   16149635760.00
     2071958400.00
     2071958400.00
     2071958400.00
@@ -847,115 +879,116 @@ diff -u datetime.out - <<EOF
     2071958400.00
     2071958400.00
     3083547038.00
-    3083547038.00
     3083512162.00
     3083512162.00
-    3083547038.00
     3083512162.00
     3083547038.00
+    3083512162.00
     3083547038.00
     3083547038.00
     3083547038.00
-    4221545305.00
+    3083512162.00
     4221635495.00
     4221635495.00
     4221545305.00
-    4221545305.00
     4221635495.00
-    4221545305.00
     4221635495.00
     4221635495.00
+    4221545305.00
+    4221545305.00
+    4221545305.00
     4221635495.00
-    5859515527.00
-    5859515527.00
     5859607673.00
     5859607673.00
     5859515527.00
     5859607673.00
-    5859515527.00
     5859607673.00
     5859607673.00
     5859607673.00
-    7472644440.00
-    7472644440.00
+    5859607673.00
+    5859515527.00
+    5859607673.00
     7472654760.00
     7472654760.00
     7472654760.00
     7472654760.00
     7472654760.00
-    7472644440.00
     7472654760.00
     7472654760.00
-    8092817891.00
+    7472644440.00
+    7472644440.00
+    7472654760.00
     8092817891.00
     8092666909.00
     8092817891.00
-    8092666909.00
     8092817891.00
     8092666909.00
-    8092666909.00
-    8092666909.00
-    8092666909.00
-   10114302235.00
+    8092817891.00
+    8092817891.00
+    8092817891.00
+    8092817891.00
+    8092817891.00
    10114356965.00
    10114356965.00
    10114302235.00
-   10114302235.00
    10114356965.00
    10114356965.00
-   10114302235.00
-   10114302235.00
+   10114356965.00
+   10114356965.00
+   10114356965.00
+   10114356965.00
    10114356965.00
    10945986229.00
    10945986229.00
+   10945872971.00
    10945986229.00
+   10945872971.00
    10945986229.00
    10945986229.00
    10945986229.00
    10945986229.00
    10945986229.00
-   10945872971.00
-   10945872971.00
    11327628891.00
    11327660709.00
    11327660709.00
-   11327628891.00
+   11327660709.00
+   11327660709.00
    11327660709.00
    11327628891.00
    11327628891.00
    11327660709.00
    11327628891.00
-   11327628891.00
-   11376658167.00
-   11376658167.00
-   11376658167.00
-   11376658167.00
-   11376658167.00
    11376658167.00
    11376609033.00
+   11376609033.00
+   11376609033.00
    11376658167.00
+   11376609033.00
    11376658167.00
+   11376609033.00
+   11376609033.00
    11376658167.00
    11391397328.00
+   11391418672.00
    11391397328.00
    11391418672.00
+   11391397328.00
+   11391397328.00
    11391418672.00
    11391418672.00
-   11391397328.00
    11391418672.00
-   11391397328.00
    11391418672.00
-   11391397328.00
    12920229944.00
    12920229944.00
    12920109256.00
    12920109256.00
    12920229944.00
-   12920229944.00
-   12920229944.00
+   12920109256.00
    12920109256.00
    12920229944.00
    12920229944.00
+   12920109256.00
+   13044663057.00
    13044508143.00
    13044663057.00
    13044663057.00
@@ -964,76 +997,75 @@ diff -u datetime.out - <<EOF
    13044663057.00
    13044663057.00
    13044508143.00
-   13044508143.00
-   13044508143.00
-   11327660709.00
+   13044663057.00
    11327660709.00
    11327660709.00
+   11327628891.00
    11327660709.00
    11327628891.00
    11327628891.00
    11327660709.00
    11327660709.00
    11327660709.00
-   11327660709.00
-   11376609033.00
-   11376609033.00
-   11376658167.00
+   11327628891.00
    11376658167.00
    11376658167.00
    11376609033.00
-   11376658167.00
+   11376609033.00
+   11376609033.00
    11376658167.00
    11376609033.00
+   11376658167.00
    11376609033.00
+   11376658167.00
+   11391418672.00
    11391418672.00
-   11391397328.00
-   11391397328.00
-   11391397328.00
    11391418672.00
    11391397328.00
-   11391397328.00
+   11391418672.00
+   11391418672.00
    11391397328.00
    11391418672.00
    11391418672.00
-   12920109256.00
+   11391418672.00
+   12920229944.00
    12920229944.00
    12920229944.00
-   12920109256.00
    12920109256.00
    12920229944.00
    12920229944.00
+   12920229944.00
    12920109256.00
-   12920109256.00
-   12920109256.00
-   13044508143.00
+   12920229944.00
+   12920229944.00
    13044508143.00
    13044663057.00
    13044663057.00
    13044663057.00
-   13044663057.00
-   13044663057.00
+   13044508143.00
    13044663057.00
    13044508143.00
    13044508143.00
-   14392420204.00
-   14392258196.00
-   14392258196.00
+   13044663057.00
+   13044508143.00
    14392420204.00
    14392420204.00
    14392258196.00
    14392420204.00
    14392420204.00
+   14392258196.00
+   14392258196.00
    14392420204.00
    14392258196.00
+   14392420204.00
+   16149621789.00
    16149635811.00
+   16149621789.00
    16149635811.00
    16149635811.00
    16149621789.00
    16149621789.00
    16149635811.00
-   16149635811.00
-   16149635811.00
    16149621789.00
    16149635811.00
 EOF