From: Ben Pfaff Date: Fri, 15 Oct 2010 04:01:56 +0000 (-0700) Subject: data-out: Convert tests for numeric output formats to Autotest framework. X-Git-Tag: v0.7.6~10 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp-builds.git;a=commitdiff_plain;h=8626dba4b37d9b07d10888daf8cef3a26e5b114c data-out: Convert tests for numeric output formats to Autotest framework. --- diff --git a/tests/automake.mk b/tests/automake.mk index fc58b3cb..0ee684d4 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -10,7 +10,6 @@ TESTS_ENVIRONMENT += LC_ALL=C TESTS_ENVIRONMENT += EXEEXT=$(EXEEXT) dist_TESTS = \ - tests/formats/num-out.sh \ tests/formats/time-in.sh \ tests/formats/360.sh @@ -19,7 +18,7 @@ TESTS = $(dist_TESTS) $(nodist_TESTS) check_PROGRAMS += \ $(nodist_TESTS) \ tests/data/datasheet-test \ - tests/formats/inexactify \ + tests/data/inexactify \ tests/libpspp/abt-test \ tests/libpspp/bt-test \ tests/libpspp/heap-test \ @@ -188,7 +187,7 @@ tests_libpspp_sparse_xarray_test_SOURCES = \ tests_libpspp_sparse_xarray_test_LDADD = gl/libgl.la $(LIBINTL) tests_libpspp_sparse_xarray_test_CPPFLAGS = $(AM_CPPFLAGS) -DASSERT_LEVEL=10 -tests_formats_inexactify_SOURCES = tests/formats/inexactify.c +tests_data_inexactify_SOURCES = tests/data/inexactify.c noinst_PROGRAMS += tests/dissect-sysfile tests_dissect_sysfile_SOURCES = \ @@ -215,13 +214,10 @@ EXTRA_DIST += \ tests/data/binhex-out.expected.gz \ tests/data/legacy-in.expected.cmp.gz \ tests/data/num-in.expected.gz \ + tests/data/num-out-cmp.pl \ + tests/data/num-out.expected.cmp.gz \ tests/data/v13.sav \ tests/data/v14.sav \ - tests/formats/num-out.expected.cmp.gz \ - tests/formats/num-out-cmp.pl \ - tests/formats/num-out-compare.pl \ - tests/formats/num-out-decmp.pl \ - tests/formats/num-out.pl \ tests/language/data-io/Book1.gnm.unzipped CLEANFILES += *.save pspp.* foo* diff --git a/tests/data/data-out.at b/tests/data/data-out.at index eb40bc46..9a41a3b5 100644 --- a/tests/data/data-out.at +++ b/tests/data/data-out.at @@ -1,5 +1,223 @@ AT_BANNER([data output (data-out)]) +AT_SETUP([numeric format output]) +AT_DATA([num-out.pl], +[[use strict; +use warnings 'all'; + +my @values = qw(0 2 9.5 27 271 999.95 2718 9999.995 27182 271828 +2718281 2**39 2**333 2**-21 -2 -9.5 -27 -271 -999.95 -2718 -9999.995 +-27182 -271828 -2718281 -2**39 -2**333 -2**-21 -0 3.125 31.25 314.125 +3141.5 31415.875 314159.25 3141592.625 31415926.5 271828182.25 +3214567890.5 31415926535.875 -3.125 -31.375 -314.125 -3141.5 +-31415.875 -314159.25 -3141592.625 -31415926.5 -271828182.25 +-3214567890.5 -31415926535.875); + +print "SET CCA=',,,'.\n"; +print "SET CCB='-,[[[,]]],-'.\n"; +print "SET CCC='((,[,],))'.\n"; +print "SET CCD=',XXX,,-'.\n"; +print "SET CCE=',,YYY,-'.\n"; +print "INPUT PROGRAM.\n"; +print "STRING EXPR(A16).\n"; +print map ("COMPUTE NUM=$_.\nCOMPUTE EXPR='$_'.\nEND CASE.\n", @values); +print "END FILE.\n"; +print "END INPUT PROGRAM.\n"; + +print "PRINT OUTFILE='output.txt'/EXPR.\n"; +for my $format qw (F COMMA DOT DOLLAR PCT E CCA CCB CCC CCD CCE N Z) { + for my $d (0...16) { + my ($min_w); + if ($format ne 'E') { + $min_w = $d + 1; + $min_w++ if $format eq 'DOLLAR' || $format eq 'PCT'; + $min_w = 2 if $min_w == 1 && ($format =~ /^CC/); + } else { + $min_w = $d + 7; + } + for my $w ($min_w...40) { + my ($f) = "$format$w.$d"; + print "PRINT OUTFILE='output.txt'/'$f: \"' NUM($f) '\"'.\n"; + } + } + print "PRINT SPACE OUTFILE='output.txt'.\n"; +} +print "EXECUTE.\n"; +]]) +AT_CHECK([$PERL num-out.pl > num-out.sps]) +AT_CHECK([pspp -O format=csv num-out.sps]) +AT_CHECK([inexactify$EXEEXT < output.txt > output.inexact]) +AT_CHECK([gzip -cd < $top_srcdir/tests/data/num-out.expected.cmp.gz > expout.cmp]) +AT_DATA([num-out-decmp.pl], +[[use strict; +use warnings 'all'; + +my (@line); +while (<>) { + if (my ($n) = /^\*(\d+)$/) { + for (1...$n) { + $line[1]++; + $line[3] = " $line[3]"; + print ' ', join ('', @line), "\n"; + } + } elsif (my ($suffix) = /^\$(.*)$/) { + for my $c (split ('', $suffix)) { + $line[1]++; + $line[4] .= $c; + print ' ', join ('', @line), "\n"; + } + } elsif (my ($prefix) = /^\^(.*)$/) { + for my $c (split ('', $prefix)) { + $line[1]++; + $line[4] = "$c$line[4]"; + print ' ', join ('', @line), "\n"; + } + } else { + @line = /^([A-Z]+)(\d+)([^"]+")( *)([^%"]*)(%?")$/; + print " $_"; + } +} +]]) +AT_CHECK([$PERL num-out-decmp.pl < expout.cmp > expout.exact]) +AT_CHECK([[inexactify < expout.exact > expout.inexact]]) +AT_DATA([num-out-compare.pl], +[[#! /usr/bin/perl -w + +use strict; +use warnings 'all'; +use Getopt::Long; + +my $exact = 0; +my $spss = 0; +my $verbose = 0; +Getopt::Long::Configure ("bundling"); +GetOptions ("e|exact!" => \$exact, + "s|spss!" => \$spss, + "v|verbose+" => \$verbose, + "h|help" => sub { usage (0) }) + or usage (1); + +sub usage { + print "$0: compare expected and actual numeric formatting output\n"; + print "usage: $0 [OPTION...] EXPECTED ACTUAL\n"; + print "where EXPECTED is the file containing expected output\n"; + print "and ACTUAL is the file containing actual output.\n"; + print "Options:\n"; + print " -e, --exact: Require numbers to be exactly equal.\n"; + print " (By default, small differences are permitted.)\n"; + print " -s, --spss: Ignore most SPSS formatting bugs in EXPECTED.\n"; + print " (A few differences are not compensated)\n"; + print " -v, --verbose: Use once to summarize errors and differences.\n"; + print " Use twice for details of differences.\n"; + exit (@_); +} + +open (EXPECTED, '<', $ARGV[0]) or die "$ARGV[0]: open: $!\n"; +open (ACTUAL, '<', $ARGV[1]) or die "$ARGV[1]: open: $!\n"; +my ($expr); +my ($bad_round) = 0; +my ($approximate) = 0; +my ($spss_wtf1) = 0; +my ($spss_wtf2) = 0; +my ($lost_sign) = 0; +my ($errors) = 0; +while (defined (my $a = ) && defined (my $b = )) { + chomp $a; + chomp $b; + if ($a eq $b) { + if ($a !~ /^\s*$/ && $a !~ /:/) { + $expr = $a; + $expr =~ s/\s*$//; + $expr =~ s/^\s*//; + } + } else { + my ($fmt, $a_out) = $a =~ /^ (.*): "(.*)"$/ or die; + my ($b_fmt, $b_out) = $b =~ /^ (.*): "(.*)"$/ or die; + die if $fmt ne $b_fmt; + die if $a_out eq $b_out; + + if (!$exact) { + if (increment ($a_out) eq $b_out || increment ($b_out) eq $a_out) { + $approximate++; + next; + } + } + if ($spss) { + if ($a_out =~ /0.*0/ && $a_out !~ /[1-9]/) { + $bad_round++; + next; + } elsif ($a_out =~ /\*/ && $a_out !~ /^\*+$/) { + $spss_wtf1++; + next; + } elsif ($expr =~ /^-/ + && $a_out =~ /^\*+$/ + && $b_out =~ /-\d(\.\d*#*)?E[-+]\d\d\d/ + && $fmt =~ /^E/) { + $spss_wtf2++; + next; + } elsif ($expr =~ /^-/ + && (($a_out !~ /-/ && $a_out =~ /[1-9]/ && $b_out =~ /-/) + || ($a_out =~ /^[0-9]+$/ && $b_out =~ /^\*+$/))) { + $lost_sign++; + next; + } + } + print "$.: $expr in $fmt: expected \"$a_out\", got \"$b_out\"\n" + if $verbose > 1; + $errors++; + } +} +while () { + print "Extra lines in $ARGV[0]\n"; + $errors++; + last; +} +while () { + print "Extra lines in $ARGV[1]\n"; + $errors++; + last; +} +if ($verbose) { + print "$errors errors\n"; + if (!$exact) { + print "$approximate approximate matches\n"; + } + if ($spss) { + print "$bad_round bad rounds\n"; + print "$spss_wtf1 SPSS WTF 1\n"; + print "$spss_wtf2 SPSS WTF 2\n"; + print "$lost_sign lost signs\n"; + } +} +exit ($errors > 0); + +# Returns the argument value incremented by one unit in its final +# decimal place. +sub increment { + local ($_) = @_; + my ($last_digit, $i); + for ($i = 0; $i < length $_; $i++) { + my ($c) = substr ($_, $i, 1); + last if ($c eq 'E'); + $last_digit = $i if $c =~ /[0-9]/; + } + return $_ if !defined $last_digit; + for ($i = $last_digit; $i >= 0; $i--) { + my ($c) = substr ($_, $i, 1); + if ($c eq '9') { + substr ($_, $i, 1) = '0'; + } elsif ($c =~ /[0-8]/) { + substr ($_, $i, 1) = chr (ord ($c) + 1); + last; + } + } + $_ = "1$_" if $i < 0; + return $_; +} +]]) +AT_CHECK([$PERL num-out-compare.pl $PSPP_NUM_OUT_COMPARE_FLAGS expout.inexact output.inexact]) +AT_CLEANUP + AT_SETUP([binary and hexadecimal output]) AT_DATA([binhex-out.sps], [dnl SET ERRORS=NONE. diff --git a/tests/data/inexactify.c b/tests/data/inexactify.c new file mode 100644 index 00000000..3b94d151 --- /dev/null +++ b/tests/data/inexactify.c @@ -0,0 +1,64 @@ +/* PSPP - a program for statistical analysis. + Copyright (C) 2006, 2010 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +#include +#include +#include +#include +#include + +/* Replaces insignificant digits by # to facilitate textual + comparisons. Not a perfect solution to the general-purpose + comparison problem, because rounding that affects earlier + digits can still cause differences. */ +int +main (void) +{ + bool in_quotes = false; + bool in_exponent = false; + int digits = 0; + + for (;;) + { + int c = getchar (); + if (c == EOF) + break; + else if (c == '\n') + in_quotes = false; + else if (c == '"') + { + in_quotes = !in_quotes; + in_exponent = false; + digits = 0; + } + else if (in_quotes && !in_exponent) + { + if (strchr ("+dDeE", c) != NULL || (c == '-' && digits)) + in_exponent = true; + else if (strchr ("0123456789}JKLMNOPQR", c) != NULL) + { + if (digits || c >= '1') + digits++; + if (digits > 13) + c = isdigit (c) ? '#' : '@'; + } + } + putchar (c); + } + return EXIT_SUCCESS; +} diff --git a/tests/data/num-out-cmp.pl b/tests/data/num-out-cmp.pl new file mode 100644 index 00000000..8e83f506 --- /dev/null +++ b/tests/data/num-out-cmp.pl @@ -0,0 +1,74 @@ +use strict; +use warnings 'all'; + +my (@prev) = (); +our ($n) = 0; +our ($suffix) = ''; +our ($prefix) = ''; +while (<>) { + s/^ //; + if (scalar (my (@line) = /^([A-Z]+)(\d+)([^"]+")( *)([^%"]*)(%?")$/) == 6) { + if (defined ($prev[0]) + && $line[0] eq $prev[0] + && $line[1] == $prev[1] + 1 + && $line[2] eq $prev[2] + && $line[5] eq $prev[5]) { + if ($line[3] eq " $prev[3]" + && $line[4] eq $prev[4]) { + flush_prefix (); + flush_suffix (); + $n++; + } elsif ($line[3] eq $prev[3] + && length ($line[4]) == length ($prev[4]) + 1 + && $prev[4] eq substr ($line[4], 0, length ($line[4]) - 1)) { + flush_n (); + flush_prefix (); + $suffix .= substr ($line[4], -1); + } elsif ($line[3] eq $prev[3] + && $prev[4] eq substr ($line[4], 1)) { + flush_n (); + flush_suffix (); + $prefix .= substr ($line[4], 0, 1); + } else { + flush (); + print $_; + } + } else { + flush (); + print $_; + } + @prev = @line; + } else { + flush (); + print $_; + @prev = (); + } +} +flush (); + +sub flush_suffix { + if ($suffix ne '') { + print "\$$suffix\n"; + $suffix = ''; + } +} + +sub flush_prefix { + if ($prefix ne '') { + print "^$prefix\n"; + $prefix = ''; + } +} + +sub flush_n { + if ($n) { + print "*$n\n"; + $n = 0; + } +} + +sub flush { + flush_prefix (); + flush_suffix (); + flush_n (); +} diff --git a/tests/data/num-out.expected.cmp.gz b/tests/data/num-out.expected.cmp.gz new file mode 100644 index 00000000..21caf25a Binary files /dev/null and b/tests/data/num-out.expected.cmp.gz differ diff --git a/tests/formats/inexactify.c b/tests/formats/inexactify.c deleted file mode 100644 index 3b94d151..00000000 --- a/tests/formats/inexactify.c +++ /dev/null @@ -1,64 +0,0 @@ -/* PSPP - a program for statistical analysis. - Copyright (C) 2006, 2010 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#include - -#include -#include -#include -#include -#include - -/* Replaces insignificant digits by # to facilitate textual - comparisons. Not a perfect solution to the general-purpose - comparison problem, because rounding that affects earlier - digits can still cause differences. */ -int -main (void) -{ - bool in_quotes = false; - bool in_exponent = false; - int digits = 0; - - for (;;) - { - int c = getchar (); - if (c == EOF) - break; - else if (c == '\n') - in_quotes = false; - else if (c == '"') - { - in_quotes = !in_quotes; - in_exponent = false; - digits = 0; - } - else if (in_quotes && !in_exponent) - { - if (strchr ("+dDeE", c) != NULL || (c == '-' && digits)) - in_exponent = true; - else if (strchr ("0123456789}JKLMNOPQR", c) != NULL) - { - if (digits || c >= '1') - digits++; - if (digits > 13) - c = isdigit (c) ? '#' : '@'; - } - } - putchar (c); - } - return EXIT_SUCCESS; -} diff --git a/tests/formats/num-out-cmp.pl b/tests/formats/num-out-cmp.pl deleted file mode 100644 index 8e83f506..00000000 --- a/tests/formats/num-out-cmp.pl +++ /dev/null @@ -1,74 +0,0 @@ -use strict; -use warnings 'all'; - -my (@prev) = (); -our ($n) = 0; -our ($suffix) = ''; -our ($prefix) = ''; -while (<>) { - s/^ //; - if (scalar (my (@line) = /^([A-Z]+)(\d+)([^"]+")( *)([^%"]*)(%?")$/) == 6) { - if (defined ($prev[0]) - && $line[0] eq $prev[0] - && $line[1] == $prev[1] + 1 - && $line[2] eq $prev[2] - && $line[5] eq $prev[5]) { - if ($line[3] eq " $prev[3]" - && $line[4] eq $prev[4]) { - flush_prefix (); - flush_suffix (); - $n++; - } elsif ($line[3] eq $prev[3] - && length ($line[4]) == length ($prev[4]) + 1 - && $prev[4] eq substr ($line[4], 0, length ($line[4]) - 1)) { - flush_n (); - flush_prefix (); - $suffix .= substr ($line[4], -1); - } elsif ($line[3] eq $prev[3] - && $prev[4] eq substr ($line[4], 1)) { - flush_n (); - flush_suffix (); - $prefix .= substr ($line[4], 0, 1); - } else { - flush (); - print $_; - } - } else { - flush (); - print $_; - } - @prev = @line; - } else { - flush (); - print $_; - @prev = (); - } -} -flush (); - -sub flush_suffix { - if ($suffix ne '') { - print "\$$suffix\n"; - $suffix = ''; - } -} - -sub flush_prefix { - if ($prefix ne '') { - print "^$prefix\n"; - $prefix = ''; - } -} - -sub flush_n { - if ($n) { - print "*$n\n"; - $n = 0; - } -} - -sub flush { - flush_prefix (); - flush_suffix (); - flush_n (); -} diff --git a/tests/formats/num-out-compare.pl b/tests/formats/num-out-compare.pl deleted file mode 100644 index be3c6239..00000000 --- a/tests/formats/num-out-compare.pl +++ /dev/null @@ -1,133 +0,0 @@ -#! /usr/bin/perl -w - -use strict; -use warnings 'all'; -use Getopt::Long; - -my $exact = 0; -my $spss = 0; -my $verbose = 0; -Getopt::Long::Configure ("bundling"); -GetOptions ("e|exact!" => \$exact, - "s|spss!" => \$spss, - "v|verbose+" => \$verbose, - "h|help" => sub { usage (0) }) - or usage (1); - -sub usage { - print "$0: compare expected and actual numeric formatting output\n"; - print "usage: $0 [OPTION...] EXPECTED ACTUAL\n"; - print "where EXPECTED is the file containing expected output\n"; - print "and ACTUAL is the file containing actual output.\n"; - print "Options:\n"; - print " -e, --exact: Require numbers to be exactly equal.\n"; - print " (By default, small differences are permitted.)\n"; - print " -s, --spss: Ignore most SPSS formatting bugs in EXPECTED.\n"; - print " (A few differences are not compensated)\n"; - print " -v, --verbose: Use once to summarize errors and differences.\n"; - print " Use twice for details of differences.\n"; - exit (@_); -} - -open (EXPECTED, '<', $ARGV[0]) or die "$ARGV[0]: open: $!\n"; -open (ACTUAL, '<', $ARGV[1]) or die "$ARGV[1]: open: $!\n"; -my ($expr); -my ($bad_round) = 0; -my ($approximate) = 0; -my ($spss_wtf1) = 0; -my ($spss_wtf2) = 0; -my ($lost_sign) = 0; -my ($errors) = 0; -while (defined (my $a = ) && defined (my $b = )) { - chomp $a; - chomp $b; - if ($a eq $b) { - if ($a !~ /^\s*$/ && $a !~ /:/) { - $expr = $a; - $expr =~ s/\s*$//; - $expr =~ s/^\s*//; - } - } else { - my ($fmt, $a_out) = $a =~ /^ (.*): "(.*)"$/ or die; - my ($b_fmt, $b_out) = $b =~ /^ (.*): "(.*)"$/ or die; - die if $fmt ne $b_fmt; - die if $a_out eq $b_out; - - if (!$exact) { - if (increment ($a_out) eq $b_out || increment ($b_out) eq $a_out) { - $approximate++; - next; - } - } - if ($spss) { - if ($a_out =~ /0.*0/ && $a_out !~ /[1-9]/) { - $bad_round++; - next; - } elsif ($a_out =~ /\*/ && $a_out !~ /^\*+$/) { - $spss_wtf1++; - next; - } elsif ($expr =~ /^-/ - && $a_out =~ /^\*+$/ - && $b_out =~ /-\d(\.\d*#*)?E[-+]\d\d\d/ - && $fmt =~ /^E/) { - $spss_wtf2++; - next; - } elsif ($expr =~ /^-/ - && (($a_out !~ /-/ && $a_out =~ /[1-9]/ && $b_out =~ /-/) - || ($a_out =~ /^[0-9]+$/ && $b_out =~ /^\*+$/))) { - $lost_sign++; - next; - } - } - print "$.: $expr in $fmt: expected \"$a_out\", got \"$b_out\"\n" - if $verbose > 1; - $errors++; - } -} -while () { - print "Extra lines in $ARGV[0]\n"; - $errors++; - last; -} -while () { - print "Extra lines in $ARGV[1]\n"; - $errors++; - last; -} -if ($verbose) { - print "$errors errors\n"; - if (!$exact) { - print "$approximate approximate matches\n"; - } - if ($spss) { - print "$bad_round bad rounds\n"; - print "$spss_wtf1 SPSS WTF 1\n"; - print "$spss_wtf2 SPSS WTF 2\n"; - print "$lost_sign lost signs\n"; - } -} -exit ($errors > 0); - -# Returns the argument value incremented by one unit in its final -# decimal place. -sub increment { - local ($_) = @_; - my ($last_digit, $i); - for ($i = 0; $i < length $_; $i++) { - my ($c) = substr ($_, $i, 1); - last if ($c eq 'E'); - $last_digit = $i if $c =~ /[0-9]/; - } - return $_ if !defined $last_digit; - for ($i = $last_digit; $i >= 0; $i--) { - my ($c) = substr ($_, $i, 1); - if ($c eq '9') { - substr ($_, $i, 1) = '0'; - } elsif ($c =~ /[0-8]/) { - substr ($_, $i, 1) = chr (ord ($c) + 1); - last; - } - } - $_ = "1$_" if $i < 0; - return $_; -} diff --git a/tests/formats/num-out-decmp.pl b/tests/formats/num-out-decmp.pl deleted file mode 100644 index 11007c00..00000000 --- a/tests/formats/num-out-decmp.pl +++ /dev/null @@ -1,28 +0,0 @@ -use strict; -use warnings 'all'; - -my (@line); -while (<>) { - if (my ($n) = /^\*(\d+)$/) { - for (1...$n) { - $line[1]++; - $line[3] = " $line[3]"; - print ' ', join ('', @line), "\n"; - } - } elsif (my ($suffix) = /^\$(.*)$/) { - for my $c (split ('', $suffix)) { - $line[1]++; - $line[4] .= $c; - print ' ', join ('', @line), "\n"; - } - } elsif (my ($prefix) = /^\^(.*)$/) { - for my $c (split ('', $prefix)) { - $line[1]++; - $line[4] = "$c$line[4]"; - print ' ', join ('', @line), "\n"; - } - } else { - @line = /^([A-Z]+)(\d+)([^"]+")( *)([^%"]*)(%?")$/; - print " $_"; - } -} diff --git a/tests/formats/num-out.expected.cmp.gz b/tests/formats/num-out.expected.cmp.gz deleted file mode 100644 index 21caf25a..00000000 Binary files a/tests/formats/num-out.expected.cmp.gz and /dev/null differ diff --git a/tests/formats/num-out.pl b/tests/formats/num-out.pl deleted file mode 100644 index 86da406b..00000000 --- a/tests/formats/num-out.pl +++ /dev/null @@ -1,41 +0,0 @@ -use strict; -use warnings 'all'; - -my @values = qw(0 2 9.5 27 271 999.95 2718 9999.995 27182 271828 -2718281 2**39 2**333 2**-21 -2 -9.5 -27 -271 -999.95 -2718 -9999.995 --27182 -271828 -2718281 -2**39 -2**333 -2**-21 -0 3.125 31.25 314.125 -3141.5 31415.875 314159.25 3141592.625 31415926.5 271828182.25 -3214567890.5 31415926535.875 -3.125 -31.375 -314.125 -3141.5 --31415.875 -314159.25 -3141592.625 -31415926.5 -271828182.25 --3214567890.5 -31415926535.875); - -print "SET CCA=',,,'.\n"; -print "SET CCB='-,[[[,]]],-'.\n"; -print "SET CCC='((,[,],))'.\n"; -print "SET CCD=',XXX,,-'.\n"; -print "SET CCE=',,YYY,-'.\n"; -print "INPUT PROGRAM.\n"; -print "STRING EXPR(A16).\n"; -print map ("COMPUTE NUM=$_.\nCOMPUTE EXPR='$_'.\nEND CASE.\n", @values); -print "END FILE.\n"; -print "END INPUT PROGRAM.\n"; - -print "PRINT OUTFILE='output.txt'/EXPR.\n"; -for my $format qw (F COMMA DOT DOLLAR PCT E CCA CCB CCC CCD CCE N Z) { - for my $d (0...16) { - my ($min_w); - if ($format ne 'E') { - $min_w = $d + 1; - $min_w++ if $format eq 'DOLLAR' || $format eq 'PCT'; - $min_w = 2 if $min_w == 1 && ($format =~ /^CC/); - } else { - $min_w = $d + 7; - } - for my $w ($min_w...40) { - my ($f) = "$format$w.$d"; - print "PRINT OUTFILE='output.txt'/'$f: \"' NUM($f) '\"'.\n"; - } - } - print "PRINT SPACE OUTFILE='output.txt'.\n"; -} -print "EXECUTE.\n"; diff --git a/tests/formats/num-out.sh b/tests/formats/num-out.sh deleted file mode 100755 index 2d0932f7..00000000 --- a/tests/formats/num-out.sh +++ /dev/null @@ -1,79 +0,0 @@ -#! /bin/sh - -TEMPDIR=/tmp/pspp-tst-$$ -mkdir -p $TEMPDIR -trap 'cd /; rm -rf $TEMPDIR' 0 - -# ensure that top_builddir are absolute -if [ -z "$top_builddir" ] ; then top_builddir=. ; fi -if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi -top_builddir=`cd $top_builddir; pwd` -PSPP=$top_builddir/src/ui/terminal/pspp$EXEEXT -: ${PERL:=perl} - -# ensure that top_srcdir is absolute -top_srcdir=`cd $top_srcdir; pwd` - -STAT_CONFIG_PATH=$top_srcdir/config -export STAT_CONFIG_PATH - -fail() -{ - echo $activity - echo FAILED - exit 1; -} - - -no_result() -{ - echo $activity - echo NO RESULT; - exit 2; -} - -pass() -{ - exit 0; -} - -cd $TEMPDIR - -activity="generate pspp syntax" -$PERL $top_srcdir/tests/formats/num-out.pl > num-out.pspp -if [ $? -ne 0 ] ; then no_result ; fi -echo -n . - -activity="run program" -$SUPERVISOR $PSPP -o pspp.csv num-out.pspp -if [ $? -ne 0 ] ; then no_result ; fi -echo -n . - -activity="inexactify results" -$top_builddir/tests/formats/inexactify$EXEEXT < output.txt > output.inexact -if [ $? -ne 0 ] ; then no_result ; fi -echo -n . - -activity="gunzip expected results" -gzip -cd < $top_srcdir/tests/formats/num-out.expected.cmp.gz > expected.txt.cmp -if [ $? -ne 0 ] ; then no_result ; fi -echo -n . - -activity="decompress expected results" -$PERL $top_srcdir/tests/formats/num-out-decmp.pl < expected.txt.cmp > expected.txt -if [ $? -ne 0 ] ; then no_result ; fi -echo -n . - -activity="inexactify expected results" -$top_builddir/tests/formats/inexactify$EXEEXT < expected.txt > expected.inexact -if [ $? -ne 0 ] ; then no_result ; fi -echo -n . - -activity="compare output" -$PERL $top_srcdir/tests/formats/num-out-compare.pl \ - $PSPP_NUM_OUT_COMPARE_FLAGS expected.inexact output.inexact -if [ $? -ne 0 ] ; then fail ; fi - -echo . - -pass