From 0cb59b775c52c59195a0935f36231fa77f0d1052 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 3 Oct 2010 05:37:39 -0700 Subject: [PATCH] NPAR TESTS: Convert CHISQUARE tests to Autotest framework. --- tests/automake.mk | 1 - tests/command/npar-chisquare.sh | 314 -------------------------------- tests/language/stats/npar.at | 218 ++++++++++++++++++++++ 3 files changed, 218 insertions(+), 315 deletions(-) delete mode 100755 tests/command/npar-chisquare.sh diff --git a/tests/automake.mk b/tests/automake.mk index 43d2c07b..b356189c 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/command/npar-chisquare.sh \ tests/command/npar-wilcoxon.sh \ tests/command/npar-sign.sh \ tests/command/permissions.sh \ diff --git a/tests/command/npar-chisquare.sh b/tests/command/npar-chisquare.sh deleted file mode 100755 index 59aec8a8..00000000 --- a/tests/command/npar-chisquare.sh +++ /dev/null @@ -1,314 +0,0 @@ -#!/bin/sh - -# This program tests the chisquare subcommand of the NPAR command. - -TEMPDIR=/tmp/pspp-tst-$$ -TESTFILE=$TEMPDIR/`basename $0`.sps - -# ensure that top_srcdir and top_builddir are absolute -if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi -if [ -z "$top_builddir" ] ; then top_builddir=. ; fi -top_srcdir=`cd $top_srcdir; pwd` -top_builddir=`cd $top_builddir; pwd` - -PSPP=$top_builddir/src/ui/terminal/pspp$EXEEXT - -STAT_CONFIG_PATH=$top_srcdir/config -export STAT_CONFIG_PATH - -LANG=C -export LANG - - -cleanup() -{ - if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then - echo "NOT cleaning $TEMPDIR" - return ; - fi - cd / - rm -rf $TEMPDIR -} - - -fail() -{ - echo $activity - echo FAILED - cleanup; - exit 1; -} - - -no_result() -{ - echo $activity - echo NO RESULT; - cleanup; - exit 2; -} - -pass() -{ - cleanup; - exit 0; -} - -mkdir -p $TEMPDIR - -cd $TEMPDIR - -activity="create file 1" -cat < $TESTFILE -DATA LIST NOTABLE LIST /x * y * w *. -BEGIN DATA. -1 2 1 -2 1 3 -3.1 1 4 -3.2 2 1 -4 2 2 -5 3 1 -1 4 2 -END DATA. - -WEIGHT BY w. - -NPAR TESTS - CHISQUARE=x y - . - -NPAR TESTS - CHISQUARE=y - /EXPECTED=3 4 5 4 - . - -NPAR TESTS - CHISQUARE=x y(2, 4) - /EXPECTED = 6 10 3 - . - -EOF -if [ $? -ne 0 ] ; then no_result ; fi - - -activity="run program 1" -$SUPERVISOR $PSPP -o pspp.csv $TESTFILE -if [ $? -ne 0 ] ; then no_result ; fi - -activity="compare output 1" -diff -c $TEMPDIR/pspp.csv - << EOF -Table: x -,Observed N,Expected N,Residual -1.00,3.00,2.33,.67 -2.00,3.00,2.33,.67 -3.10,4.00,2.33,1.67 -3.20,1.00,2.33,-1.33 -4.00,2.00,2.33,-.33 -5.00,1.00,2.33,-1.33 -Total,14.00,, - -Table: y -,Observed N,Expected N,Residual -1.00,7.00,3.50,3.50 -2.00,4.00,3.50,.50 -3.00,1.00,3.50,-2.50 -4.00,2.00,3.50,-1.50 -Total,14.00,, - -Table: Test Statistics -,x,y -Chi-Square,3.14,6.00 -df,5,3 -Asymp. Sig.,.68,.11 - -Table: y -,Observed N,Expected N,Residual -1.00,7.00,2.63,4.38 -2.00,4.00,3.50,.50 -3.00,1.00,4.38,-3.38 -4.00,2.00,3.50,-1.50 -Total,14.00,, - -Table: Test Statistics -,y -Chi-Square,10.61 -df,3 -Asymp. Sig.,.01 - -Table: Frequencies -,x,,,,y,,, -,Category,Observed N,Expected N,Residual,Category,Observed N,Expected N,Residual -1,2.00,3.00,3.16,-.16,2.00,4.00,2.21,1.79 -2,3.00,5.00,5.26,-.26,3.00,1.00,3.68,-2.68 -3,4.00,2.00,1.58,.42,4.00,2.00,1.11,.89 -Total,,10.00,,,,7.00,, - -Table: Test Statistics -,x,y -Chi-Square,.13,4.13 -df,2,2 -Asymp. Sig.,.94,.13 -EOF -if [ $? -ne 0 ] ; then fail ; fi - - -activity="create file 2" -cat < $TESTFILE -DATA LIST NOTABLE LIST /x * y * w *. -BEGIN DATA. -1 2 1 -2 1 3 -3.1 1 4 -3.2 2 1 -4 2 2 -5 3 1 -1 4 2 -END DATA. - -WEIGHT BY w. - -NPAR TESTS - CHISQUARE=y - /EXPECTED = 3 4 5 4 3 1 - . -EOF -if [ $? -ne 0 ] ; then no_result ; fi - - -activity="run program 2" -$SUPERVISOR $PSPP -o pspp.csv $TESTFILE -e $TEMPDIR/output -if [ $? -eq 0 ] ; then no_result ; fi - -activity="compare errors 2" -perl -pi -e 's/^\s*$//g' $TEMPDIR/output -diff -b $TEMPDIR/output - << EOF -error: CHISQUARE test specified 6 expected values, but 4 distinct values were encountered in variable y. -EOF -if [ $? -ne 0 ] ; then fail ; fi - - -activity="create file 3" -cat < $TESTFILE -DATA LIST NOTABLE LIST /x * y * w * . -BEGIN DATA. -1 2 1 -2 1 3 -3.1 1 4 -3.2 2 1 -4 2 2 -5 3 1 -1 4 2 -. 5 1 -END DATA. - -WEIGHT BY w. - -MISSING VALUES x (4). - -NPAR TESTS - CHISQUARE=x y(-2,5) - /MISSING=ANALYSIS - /STATISTICS=DESCRIPTIVES - . -EOF -if [ $? -ne 0 ] ; then no_result ; fi - - -activity="run program 3" -$SUPERVISOR $PSPP -o pspp.csv $TESTFILE -if [ $? -ne 0 ] ; then no_result ; fi - - -activity="compare output 3" -diff -c $TEMPDIR/pspp.csv - < $TESTFILE -DATA LIST NOTABLE LIST /x * y * w * . -BEGIN DATA. -1 2 1 -2 1 3 -3.1 1 4 -3.2 2 1 -4 2 2 -5 3 1 -1 4 2 -. 5 1 -END DATA. - -WEIGHT BY w. - -* MISSING VALUES x (4). - -NPAR TESTS - CHISQUARE=x y(-2,5) - /MISSING=LISTWISE - /STATISTICS=DESCRIPTIVES - . -EOF -if [ $? -ne 0 ] ; then no_result ; fi - - -activity="run program 4" -$SUPERVISOR $PSPP -o pspp.csv $TESTFILE -if [ $? -ne 0 ] ; then no_result ; fi - - -activity="compare output 4" -diff -c $TEMPDIR/pspp.csv - <