1 AT_BANNER([data input (data-in)])
3 m4_divert_push([PREPARE_TESTS])
5 cat > my-rand.pl <<'EOF'
6 # This random number generator and the test for it below are drawn
7 # from Park and Miller, "Random Number Generators: Good Ones are Hard
8 # to Come By", Communications of the ACM 31:10 (October 1988). It is
9 # documented to function properly on systems with a 46-bit or longer
10 # real significand, which includes systems that have 64-bit IEEE reals
11 # (with 53-bit significand). The test should catch any systems for
12 # which this is not true, in any case.
19 my ($tmp) = $a * $seed;
20 $seed = $tmp - $m * int ($tmp / $m);
21 return $seed % $modulo;
24 cat > test-my-rand.pl <<'EOF'
29 my_rand (1) foreach 1...10000;
31 die $seed if $seed != 1043618065;
34 m4_divert_pop([PREPARE_TESTS])
36 AT_SETUP([numeric input formats])
37 AT_KEYWORDS([data-in])
39 AT_CHECK([$PERL test-my-rand.pl])
49 for my $number (0, 1, .5, .015625, 123) {
50 my ($base_exp) = floor ($number ? log10 ($number) : 0);
51 for my $offset (-3...3) {
52 my ($exponent) = $base_exp + $offset;
53 my ($fraction) = $number / 10**$offset;
55 permute_zeros ($fraction, $exponent);
60 my ($fraction, $exponent) = @_;
62 my ($frac_rep) = sprintf ("%f", $fraction);
63 my ($leading_zeros) = length (($frac_rep =~ /^(0*)/)[0]);
64 my ($trailing_zeros) = length (($frac_rep =~ /(\.?0*)$/)[0]);
65 for my $i (0...$leading_zeros) {
66 for my $j (0...$trailing_zeros) {
67 my ($trimmed) = substr ($frac_rep, $i,
68 length ($frac_rep) - $i - $j);
69 next if $trimmed eq '.' || $trimmed eq '';
71 permute_commas ($trimmed, $exponent);
77 my ($frac_rep, $exponent) = @_;
78 permute_dot_comma ($frac_rep, $exponent);
79 my ($pos) = int (my_rand (length ($frac_rep) + 1));
80 $frac_rep = substr ($frac_rep, 0, $pos) . "," . substr ($frac_rep, $pos);
81 permute_dot_comma ($frac_rep, $exponent);
84 sub permute_dot_comma {
85 my ($frac_rep, $exponent) = @_;
86 permute_exponent_syntax ($frac_rep, $exponent);
87 if ($frac_rep =~ /[,.]/) {
88 $frac_rep =~ tr/.,/,./;
89 permute_exponent_syntax ($frac_rep, $exponent);
93 sub permute_exponent_syntax {
94 my ($frac_rep, $exponent) = @_;
97 @exp_reps = pick ('', 'e0', 'e-0', 'e+0', '-0', '+0');
98 } elsif ($exponent > 0) {
99 @exp_reps = pick ("e$exponent", "e+$exponent", "+$exponent");
101 my ($abs_exp) = -$exponent;
102 @exp_reps = pick ("e-$abs_exp", , "e-$abs_exp", "-$abs_exp");
104 permute_sign_and_affix ($frac_rep, $_) foreach @exp_reps;
107 sub permute_sign_and_affix {
108 my ($frac_rep, $exp_rep) = @_;
109 for my $prefix (pick ('', '$'),
110 pick ('-', '-$', '$-', '$-$'),
111 pick ('+', '+$', '$+', '$+$')) {
112 for my $suffix ('', '%') {
113 permute_spaces ("$prefix$frac_rep$exp_rep$suffix");
120 $s =~ s/([-+\$e%])/ $1 /g;
121 my (@fields) = split (' ', $s);
122 print join ('', @fields), "\n";
125 my ($pos) = int (my_rand ($#fields)) + 1;
126 print join ('', @fields[0...$pos - 1]);
128 print join ('', @fields[$pos...$#fields]);
134 return $_[int (my_rand ($#_ + 1))];
137 AT_CHECK([$PERL num-in.pl > num-in.data])
138 AT_DATA([num-in.sps], [dnl
141 SET MXWARNS=10000000.
142 DATA LIST FILE='num-in.data' NOTABLE/
149 PRINT OUTFILE='num-in.out'/all (6f10.4).
152 AT_CHECK([pspp -O format=csv num-in.sps])
153 AT_CHECK([gzip -cd < $top_srcdir/tests/data/num-in.expected.gz > expout])
154 AT_CHECK([cat num-in.out], [0], [expout])
157 dnl Some very old version of PSPP crashed reading big numbers,
158 dnl so this checks for regressions.
159 AT_SETUP([reading big numbers])
160 AT_KEYWORDS([data-in])
161 AT_DATA([bignum.txt], [dnl
192 199999999999999999999
193 1234567890123456789012
194 19999999999999999999999
195 123456789012345678901234
196 1999999999999999999999999
197 12345678901234567890123456
198 199999999999999999999999999
199 1234567890123456789012345678
200 19999999999999999999999999999
201 123456789012345678901234567890
202 1999999999999999999999999999999
203 12345678901234567890123456789012
204 199999999999999999999999999999999
205 1234567890123456789012345678901234
206 19999999999999999999999999999999999
207 123456789012345678901234567890123456
208 1999999999999999999999999999999999999
209 12345678901234567890123456789012345678
210 199999999999999999999999999999999999999
211 1234567890123456789012345678901234567890
212 1999999999999999999999999999999999999999
226 AT_DATA([bignum.sps], [dnl
227 title 'Test use of big numbers'.
229 *** Do the portable output.
230 data list file='bignum.txt'/BIGNUM 1-40.
233 *** Do the nonportable output for fun.
236 AT_CHECK([pspp -o pspp.csv bignum.sps], [0], [ignore])
239 AT_SETUP([binary and hexadecimal input (IB, PIB, and PIBHEX formats)])
240 AT_CHECK([$PERL -e 'print pack "n", $_ foreach 0...65535' > binhex-in.data])
241 AT_CHECK([wc -c < binhex-in.data], [0], [131072
243 AT_DATA([binhex-in.sps], [dnl
246 SET MXWARNS=10000000.
248 FILE HANDLE data/NAME='binhex-in.data'/MODE=IMAGE/LRECL=2.
249 DATA LIST FILE=data NOTABLE/ib 1-2 (IB) pib 1-2 (PIB) pibhex 1-2 (PIBHEX).
250 COMPUTE x=$CASENUM - 1.
251 PRINT OUTFILE='binhex-in.out'/x (PIBHEX4) ' ' ib pib pibhex.
254 AT_CHECK([gzip -cd < $top_srcdir/tests/data/binhex-in.expected.cmp.gz | \
255 $PERL -pe "printf ' %04X ', $.-1" > expout])
256 AT_CHECK([pspp -O format=csv binhex-in.sps], [0])
257 AT_CHECK([cat binhex-in.out], [0], [expout])
260 AT_SETUP([BCD input (P and PK formats)])
261 AT_CHECK([$PERL -e 'print pack "n", $_ foreach 0...65535' > bcd-in.data])
262 AT_CHECK([wc -c < bcd-in.data], [0], [131072
264 AT_DATA([bcd-in.sps], [dnl
266 SET MXWARNS=10000000.
268 FILE HANDLE data/NAME='bcd-in.data'/MODE=IMAGE/LRECL=2.
269 DATA LIST FILE=data NOTABLE/p 1-2 (P) pk 1-2 (PK).
270 COMPUTE x=$CASENUM - 1.
271 PRINT OUTFILE='bcd-in.out'/x (PIBHEX4) ' ' P PK.
274 AT_CHECK([gzip -cd < $top_srcdir/tests/data/bcd-in.expected.cmp.gz | \
275 $PERL -pe "printf ' %04X ', $.-1" > expout])
276 AT_CHECK([pspp -O format=csv bcd-in.sps])
277 AT_CHECK([cat bcd-in.out], [0], [expout])
280 AT_SETUP([legacy input (N and Z formats)])
281 AT_CHECK([$PERL -e 'print pack "n", $_ foreach 0...65535' > legacy-in.data])
282 AT_CHECK([wc -c < legacy-in.data], [0], [131072
284 AT_DATA([legacy-in.sps], [dnl
286 SET MXWARNS=10000000.
288 FILE HANDLE data/NAME='legacy-in.data'/MODE=IMAGE/LRECL=2.
289 DATA LIST NOTABLE FILE=data/n 1-2 (N) z 1-2 (z).
290 COMPUTE x=$CASENUM - 1.
291 PRINT OUTFILE='legacy-in.out'/x (PIBHEX4) ' ' N Z.
294 AT_CHECK([gzip -cd < $top_srcdir/tests/data/legacy-in.expected.cmp.gz | \
295 $PERL -pe "printf ' %04X ', $.-1" > expout])
296 AT_CHECK([pspp -O format=csv legacy-in.sps])
297 AT_CHECK([cat legacy-in.out], [0], [expout])
300 AT_SETUP([WKDAY input format])
301 AT_DATA([wkday.sps], [dnl
302 DATA LIST NOTABLE /wkday2 1-2 (wkday)
310 wkday10 1-10 (wkday).
323 FORMATS ALL (WKDAY2).
324 PRINT OUTFILE='wkday.out'/ALL.
327 AT_CHECK([pspp -O format=csv wkday.sps], [0], [dnl
328 wkday.sps:20.1-2: warning: Data for variable wkday2 is not valid as format WKDAY: Unrecognized weekday name. At least the first two letters of an English weekday name must be specified.
330 wkday.sps:20.1-3: warning: Data for variable wkday3 is not valid as format WKDAY: Unrecognized weekday name. At least the first two letters of an English weekday name must be specified.
332 wkday.sps:20.1-4: warning: Data for variable wkday4 is not valid as format WKDAY: Unrecognized weekday name. At least the first two letters of an English weekday name must be specified.
334 wkday.sps:20.1-5: warning: Data for variable wkday5 is not valid as format WKDAY: Unrecognized weekday name. At least the first two letters of an English weekday name must be specified.
336 wkday.sps:20.1-6: warning: Data for variable wkday6 is not valid as format WKDAY: Unrecognized weekday name. At least the first two letters of an English weekday name must be specified.
338 wkday.sps:20.1-7: warning: Data for variable wkday7 is not valid as format WKDAY: Unrecognized weekday name. At least the first two letters of an English weekday name must be specified.
340 wkday.sps:20.1-8: warning: Data for variable wkday8 is not valid as format WKDAY: Unrecognized weekday name. At least the first two letters of an English weekday name must be specified.
342 wkday.sps:20.1-9: warning: Data for variable wkday9 is not valid as format WKDAY: Unrecognized weekday name. At least the first two letters of an English weekday name must be specified.
344 wkday.sps:20.1-10: warning: Data for variable wkday10 is not valid as format WKDAY: Unrecognized weekday name. At least the first two letters of an English weekday name must be specified.
346 AT_CHECK([cat wkday.out], [0], [dnl
347 . . . . . . . . . @&t@
348 . . . . . . . . . @&t@
349 MO MO MO MO MO MO MO MO MO @&t@
350 TU TU TU TU TU TU TU TU TU @&t@
351 WE WE WE WE WE WE WE WE WE @&t@
352 TH TH TH TH TH TH TH TH TH @&t@
353 FR FR FR FR FR FR FR FR FR @&t@
354 SA SA SA SA SA SA SA SA SA @&t@
355 SU SU SU SU SU SU SU SU SU @&t@
356 . . . . . . . . . @&t@
360 AT_SETUP([MONTH input format])
361 AT_DATA([month.sps], [dnl
362 DATA LIST NOTABLE /month3 1-3 (MONTH)
369 month10 1-10 (MONTH).
418 FORMATS ALL (MONTH3).
419 PRINT OUTFILE='month.out'/ALL.
422 AT_CHECK([pspp -O format=csv month.sps], [0], [dnl
423 month.sps:15.1-4: warning: Data for variable month4 is not valid as format MONTH: Unrecognized month format. Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names.
425 month.sps:15.1-5: warning: Data for variable month5 is not valid as format MONTH: Unrecognized month format. Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names.
427 month.sps:15.1-6: warning: Data for variable month6 is not valid as format MONTH: Unrecognized month format. Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names.
429 month.sps:15.1-7: warning: Data for variable month7 is not valid as format MONTH: Unrecognized month format. Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names.
431 month.sps:15.1-8: warning: Data for variable month8 is not valid as format MONTH: Unrecognized month format. Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names.
433 month.sps:15.1-9: warning: Data for variable month9 is not valid as format MONTH: Unrecognized month format. Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names.
435 month.sps:15.1-10: warning: Data for variable month10 is not valid as format MONTH: Unrecognized month format. Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names.
437 month.sps:26.1-3: warning: Data for variable month3 is not valid as format MONTH: Unrecognized month format. Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names.
439 month.sps:26.1-4: warning: Data for variable month4 is not valid as format MONTH: Unrecognized month format. Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names.
441 month.sps:26.1-5: warning: Data for variable month5 is not valid as format MONTH: Unrecognized month format. Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names.
443 month.sps:26.1-6: warning: Data for variable month6 is not valid as format MONTH: Unrecognized month format. Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names.
445 month.sps:26.1-7: warning: Data for variable month7 is not valid as format MONTH: Unrecognized month format. Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names.
447 month.sps:26.1-8: warning: Data for variable month8 is not valid as format MONTH: Unrecognized month format. Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names.
449 month.sps:26.1-9: warning: Data for variable month9 is not valid as format MONTH: Unrecognized month format. Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names.
451 month.sps:26.1-10: warning: Data for variable month10 is not valid as format MONTH: Unrecognized month format. Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names.
453 month.sps:39.1-3: warning: Data for variable month3 is not valid as format MONTH: Unrecognized month format. Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names.
455 month.sps:39.1-4: warning: Data for variable month4 is not valid as format MONTH: Unrecognized month format. Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names.
457 month.sps:39.1-5: warning: Data for variable month5 is not valid as format MONTH: Unrecognized month format. Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names.
459 month.sps:39.1-6: warning: Data for variable month6 is not valid as format MONTH: Unrecognized month format. Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names.
461 month.sps:39.1-7: warning: Data for variable month7 is not valid as format MONTH: Unrecognized month format. Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names.
463 month.sps:39.1-8: warning: Data for variable month8 is not valid as format MONTH: Unrecognized month format. Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names.
465 month.sps:39.1-9: warning: Data for variable month9 is not valid as format MONTH: Unrecognized month format. Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names.
467 month.sps:39.1-10: warning: Data for variable month10 is not valid as format MONTH: Unrecognized month format. Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names.
469 AT_CHECK([cat month.out], [0], [dnl
472 JAN JAN JAN JAN JAN JAN JAN JAN @&t@
473 FEB FEB FEB FEB FEB FEB FEB FEB @&t@
474 MAR MAR MAR MAR MAR MAR MAR MAR @&t@
475 MAR . . . . . . . @&t@
476 APR APR APR APR APR APR APR APR @&t@
477 MAY MAY MAY MAY MAY MAY MAY MAY @&t@
478 JUN JUN JUN JUN JUN JUN JUN JUN @&t@
479 JUL JUL JUL JUL JUL JUL JUL JUL @&t@
480 JUL AUG AUG AUG AUG AUG AUG AUG @&t@
481 SEP SEP SEP SEP SEP SEP SEP SEP @&t@
482 JUL AUG AUG AUG AUG AUG AUG AUG @&t@
483 OCT OCT OCT OCT OCT OCT OCT OCT @&t@
484 NOV NOV NOV NOV NOV NOV NOV NOV @&t@
485 DEC DEC DEC DEC DEC DEC DEC DEC @&t@
487 JAN JAN JAN JAN JAN JAN JAN JAN @&t@
488 FEB FEB FEB FEB FEB FEB FEB FEB @&t@
489 MAR MAR MAR MAR MAR MAR MAR MAR @&t@
490 APR APR APR APR APR APR APR APR @&t@
491 MAY MAY MAY MAY MAY MAY MAY MAY @&t@
492 JUN JUN JUN JUN JUN JUN JUN JUN @&t@
493 JUL JUL JUL JUL JUL JUL JUL JUL @&t@
494 AUG AUG AUG AUG AUG AUG AUG AUG @&t@
495 SEP SEP SEP SEP SEP SEP SEP SEP @&t@
496 OCT OCT OCT OCT OCT OCT OCT OCT @&t@
497 NOV NOV NOV NOV NOV NOV NOV NOV @&t@
498 DEC DEC DEC DEC DEC DEC DEC DEC @&t@
500 JAN JAN JAN JAN JAN JAN JAN JAN @&t@
501 JAN JAN JAN JAN JAN JAN JAN JAN @&t@
502 FEB FEB FEB FEB FEB FEB FEB FEB @&t@
503 FEB FEB FEB FEB FEB FEB FEB FEB @&t@
504 MAR MAR MAR MAR MAR MAR MAR MAR @&t@
505 MAR MAR MAR MAR MAR MAR MAR MAR @&t@
506 APR APR APR APR APR APR APR APR @&t@
507 MAY MAY MAY MAY MAY MAY MAY MAY @&t@
508 JUN JUN JUN JUN JUN JUN JUN JUN @&t@
509 JUL JUL JUL JUL JUL JUL JUL JUL @&t@
510 AUG AUG AUG AUG AUG AUG AUG AUG @&t@
511 SEP SEP SEP SEP SEP SEP SEP SEP @&t@
512 OCT OCT OCT OCT OCT OCT OCT OCT @&t@
513 NOV NOV NOV NOV NOV NOV NOV NOV @&t@
514 DEC DEC DEC DEC DEC DEC DEC DEC @&t@
515 DEC DEC DEC DEC DEC DEC DEC DEC @&t@