X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=tests%2Fdata%2Fdata-in.at;h=654c70e3eb17c86488f886587c7b7ba774e8650f;hb=5d5de1adfffc66bac5872b18b3766bc32bf3464d;hp=77827b0b01aec5d8e2700910d1701d59aabbe1b5;hpb=493527639c58bd78c7951260b32a6dcfc68abaee;p=pspp-builds.git diff --git a/tests/data/data-in.at b/tests/data/data-in.at index 77827b0b..654c70e3 100644 --- a/tests/data/data-in.at +++ b/tests/data/data-in.at @@ -1,5 +1,159 @@ AT_BANNER([data input (data-in)]) +m4_divert_push([PREPARE_TESTS]) +data_in_prng () { + 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 + 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 +} +m4_divert_pop([PREPARE_TESTS]) + +AT_SETUP([numeric input formats]) +AT_KEYWORDS([data-in]) +data_in_prng +AT_CHECK([$PERL test-my-rand.pl]) +AT_DATA([num-in.pl], +[[#! /usr/bin/perl + +use POSIX; +use strict; +use warnings; + +do 'my-rand.pl'; + +for my $number (0, 1, .5, .015625, 123) { + my ($base_exp) = floor ($number ? log10 ($number) : 0); + for my $offset (-3...3) { + my ($exponent) = $base_exp + $offset; + my ($fraction) = $number / 10**$offset; + + permute_zeros ($fraction, $exponent); + } +} + +sub permute_zeros { + my ($fraction, $exponent) = @_; + + my ($frac_rep) = sprintf ("%f", $fraction); + my ($leading_zeros) = length (($frac_rep =~ /^(0*)/)[0]); + my ($trailing_zeros) = length (($frac_rep =~ /(\.?0*)$/)[0]); + for my $i (0...$leading_zeros) { + for my $j (0...$trailing_zeros) { + my ($trimmed) = substr ($frac_rep, $i, + length ($frac_rep) - $i - $j); + next if $trimmed eq '.' || $trimmed eq ''; + + permute_commas ($trimmed, $exponent); + } + } +} + +sub permute_commas { + my ($frac_rep, $exponent) = @_; + permute_dot_comma ($frac_rep, $exponent); + my ($pos) = int (my_rand (length ($frac_rep) + 1)); + $frac_rep = substr ($frac_rep, 0, $pos) . "," . substr ($frac_rep, $pos); + permute_dot_comma ($frac_rep, $exponent); +} + +sub permute_dot_comma { + my ($frac_rep, $exponent) = @_; + permute_exponent_syntax ($frac_rep, $exponent); + if ($frac_rep =~ /[,.]/) { + $frac_rep =~ tr/.,/,./; + permute_exponent_syntax ($frac_rep, $exponent); + } +} + +sub permute_exponent_syntax { + my ($frac_rep, $exponent) = @_; + my (@exp_reps); + if ($exponent == 0) { + @exp_reps = pick ('', 'e0', 'e-0', 'e+0', '-0', '+0'); + } elsif ($exponent > 0) { + @exp_reps = pick ("e$exponent", "e+$exponent", "+$exponent"); + } else { + my ($abs_exp) = -$exponent; + @exp_reps = pick ("e-$abs_exp", , "e-$abs_exp", "-$abs_exp"); + } + permute_sign_and_affix ($frac_rep, $_) foreach @exp_reps; +} + +sub permute_sign_and_affix { + my ($frac_rep, $exp_rep) = @_; + for my $prefix (pick ('', '$'), + pick ('-', '-$', '$-', '$-$'), + pick ('+', '+$', '$+', '$+$')) { + for my $suffix ('', '%') { + permute_spaces ("$prefix$frac_rep$exp_rep$suffix"); + } + } +} + +sub permute_spaces { + my ($s) = @_; + $s =~ s/([-+\$e%])/ $1 /g; + my (@fields) = split (' ', $s); + print join ('', @fields), "\n"; + + if ($#fields > 0) { + my ($pos) = int (my_rand ($#fields)) + 1; + print join ('', @fields[0...$pos - 1]); + print " "; + print join ('', @fields[$pos...$#fields]); + print "\n"; + } +} + +sub pick { + return $_[int (my_rand ($#_ + 1))]; +} +]]) +AT_CHECK([$PERL num-in.pl > num-in.data]) +AT_DATA([num-in.sps], [dnl +SET ERRORS=NONE. +SET MXERRS=10000000. +SET MXWARNS=10000000. +DATA LIST FILE='num-in.data' NOTABLE/ + f 1-40 (f) + comma 1-40 (comma) + dot 1-40 (dot) + dollar 1-40 (dollar) + pct 1-40 (pct) + e 1-40 (e). +PRINT OUTFILE='num-in.out'/all (6f10.4). +EXECUTE. +]) +AT_CHECK([pspp -O format=csv num-in.sps]) +AT_CHECK([gzip -cd < $top_srcdir/tests/data/num-in.expected.gz > expout]) +AT_CHECK([cat num-in.out], [0], [expout]) +AT_CLEANUP + dnl Some very old version of PSPP crashed reading big numbers, dnl so this checks for regressions. AT_SETUP([reading big numbers]) @@ -82,6 +236,27 @@ descriptives BIGNUM. AT_CHECK([pspp -o pspp.csv bignum.sps], [0], [ignore]) AT_CLEANUP +AT_SETUP([binary and hexadecimal input (IB, PIB, and PIBHEX formats)]) +AT_CHECK([$PERL -e 'print pack "n", $_ foreach 0...65535' > binhex-in.data]) +AT_CHECK([wc -c < binhex-in.data], [0], [131072 +]) +AT_DATA([binhex-in.sps], [dnl +SET RIB=MSBFIRST. +SET ERRORS=NONE. +SET MXWARNS=10000000. +SET MXERRS=10000000. +FILE HANDLE data/NAME='binhex-in.data'/MODE=IMAGE/LRECL=2. +DATA LIST FILE=data NOTABLE/ib 1-2 (IB) pib 1-2 (PIB) pibhex 1-2 (PIBHEX). +COMPUTE x=$CASENUM - 1. +PRINT OUTFILE='binhex-in.out'/x (PIBHEX4) ' ' ib pib pibhex. +EXECUTE. +]) +AT_CHECK([gzip -cd < $top_srcdir/tests/data/binhex-in.expected.cmp.gz | \ + $PERL -pe "printf ' %04X ', $.-1" > expout]) +AT_CHECK([pspp -O format=csv binhex-in.sps], [0]) +AT_CHECK([cat binhex-in.out], [0], [expout]) +AT_CLEANUP + AT_SETUP([BCD input (P and PK formats)]) AT_CHECK([$PERL -e 'print pack "n", $_ foreach 0...65535' > bcd-in.data]) AT_CHECK([wc -c < bcd-in.data], [0], [131072 @@ -121,3 +296,222 @@ AT_CHECK([gzip -cd < $top_srcdir/tests/data/legacy-in.expected.cmp.gz | \ AT_CHECK([pspp -O format=csv legacy-in.sps]) AT_CHECK([cat legacy-in.out], [0], [expout]) AT_CLEANUP + +AT_SETUP([WKDAY input format]) +AT_DATA([wkday.sps], [dnl +DATA LIST NOTABLE /wkday2 1-2 (wkday) + wkday3 1-3 (wkday) + wkday4 1-4 (wkday) + wkday5 1-5 (wkday) + wkday6 1-6 (wkday) + wkday7 1-7 (wkday) + wkday8 1-8 (wkday) + wkday9 1-9 (wkday) + wkday10 1-10 (wkday). +BEGIN DATA. + +. +monady +tuseday +WEDENSDAY +Thurdsay +fRidya +SAturady +sudnay +sturday +END DATA. +FORMATS ALL (WKDAY2). +PRINT OUTFILE='wkday.out'/ALL. +EXECUTE. +]) +AT_CHECK([pspp -O format=csv wkday.sps], [0], [dnl +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. +]) +AT_CHECK([cat wkday.out], [0], [dnl + . . . . . . . . . @&t@ + . . . . . . . . . @&t@ + MO MO MO MO MO MO MO MO MO @&t@ + TU TU TU TU TU TU TU TU TU @&t@ + WE WE WE WE WE WE WE WE WE @&t@ + TH TH TH TH TH TH TH TH TH @&t@ + FR FR FR FR FR FR FR FR FR @&t@ + SA SA SA SA SA SA SA SA SA @&t@ + SU SU SU SU SU SU SU SU SU @&t@ + . . . . . . . . . @&t@ +]) +AT_CLEANUP + +AT_SETUP([MONTH input format]) +AT_DATA([month.sps], [dnl +DATA LIST NOTABLE /month3 1-3 (MONTH) + month4 1-4 (MONTH) + month5 1-5 (MONTH) + month6 1-6 (MONTH) + month7 1-7 (MONTH) + month8 1-8 (MONTH) + month9 1-9 (MONTH) + month10 1-10 (MONTH). +BEGIN DATA. + +. +i +ii +iii +iiii +iv +v +vi +vii +viii +ix +viiii +x +xi +xii +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +january +JANAURY +February +fEbraury +MArch +marhc +apRIL +may +june +july +august +september +october +november +decmeber +december +END DATA. +FORMATS ALL (MONTH3). +PRINT OUTFILE='month.out'/ALL. +EXECUTE. +]) +AT_CHECK([pspp -O format=csv month.sps], [0], [dnl +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. + +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. +]) +AT_CHECK([cat month.out], [0], [dnl + . . . . . . . . @&t@ + . . . . . . . . @&t@ + JAN JAN JAN JAN JAN JAN JAN JAN @&t@ + FEB FEB FEB FEB FEB FEB FEB FEB @&t@ + MAR MAR MAR MAR MAR MAR MAR MAR @&t@ + MAR . . . . . . . @&t@ + APR APR APR APR APR APR APR APR @&t@ + MAY MAY MAY MAY MAY MAY MAY MAY @&t@ + JUN JUN JUN JUN JUN JUN JUN JUN @&t@ + JUL JUL JUL JUL JUL JUL JUL JUL @&t@ + JUL AUG AUG AUG AUG AUG AUG AUG @&t@ + SEP SEP SEP SEP SEP SEP SEP SEP @&t@ + JUL AUG AUG AUG AUG AUG AUG AUG @&t@ + OCT OCT OCT OCT OCT OCT OCT OCT @&t@ + NOV NOV NOV NOV NOV NOV NOV NOV @&t@ + DEC DEC DEC DEC DEC DEC DEC DEC @&t@ + . . . . . . . . @&t@ + JAN JAN JAN JAN JAN JAN JAN JAN @&t@ + FEB FEB FEB FEB FEB FEB FEB FEB @&t@ + MAR MAR MAR MAR MAR MAR MAR MAR @&t@ + APR APR APR APR APR APR APR APR @&t@ + MAY MAY MAY MAY MAY MAY MAY MAY @&t@ + JUN JUN JUN JUN JUN JUN JUN JUN @&t@ + JUL JUL JUL JUL JUL JUL JUL JUL @&t@ + AUG AUG AUG AUG AUG AUG AUG AUG @&t@ + SEP SEP SEP SEP SEP SEP SEP SEP @&t@ + OCT OCT OCT OCT OCT OCT OCT OCT @&t@ + NOV NOV NOV NOV NOV NOV NOV NOV @&t@ + DEC DEC DEC DEC DEC DEC DEC DEC @&t@ + . . . . . . . . @&t@ + JAN JAN JAN JAN JAN JAN JAN JAN @&t@ + JAN JAN JAN JAN JAN JAN JAN JAN @&t@ + FEB FEB FEB FEB FEB FEB FEB FEB @&t@ + FEB FEB FEB FEB FEB FEB FEB FEB @&t@ + MAR MAR MAR MAR MAR MAR MAR MAR @&t@ + MAR MAR MAR MAR MAR MAR MAR MAR @&t@ + APR APR APR APR APR APR APR APR @&t@ + MAY MAY MAY MAY MAY MAY MAY MAY @&t@ + JUN JUN JUN JUN JUN JUN JUN JUN @&t@ + JUL JUL JUL JUL JUL JUL JUL JUL @&t@ + AUG AUG AUG AUG AUG AUG AUG AUG @&t@ + SEP SEP SEP SEP SEP SEP SEP SEP @&t@ + OCT OCT OCT OCT OCT OCT OCT OCT @&t@ + NOV NOV NOV NOV NOV NOV NOV NOV @&t@ + DEC DEC DEC DEC DEC DEC DEC DEC @&t@ + DEC DEC DEC DEC DEC DEC DEC DEC @&t@ +]) +AT_CLEANUP