From a67571068a8d01da4a810c65bc230cea2b1d7a3f Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 2 Oct 2010 15:01:54 -0700 Subject: [PATCH] NPAR TESTS: Convert BINOMAL tests to Autotest framework. --- tests/automake.mk | 2 +- .../stats/npar.at} | 334 +++++++----------- 2 files changed, 133 insertions(+), 203 deletions(-) rename tests/{command/npar-binomial.sh => language/stats/npar.at} (59%) mode change 100755 => 100644 diff --git a/tests/automake.mk b/tests/automake.mk index 90db8c5b..43d2c07b 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-binomial.sh \ tests/command/npar-chisquare.sh \ tests/command/npar-wilcoxon.sh \ tests/command/npar-sign.sh \ @@ -384,6 +383,7 @@ TESTSUITE_AT = \ tests/language/stats/factor.at \ tests/language/stats/flip.at \ tests/language/stats/frequencies.at \ + tests/language/stats/npar.at \ tests/language/stats/oneway.at \ tests/language/utilities/insert.at \ tests/language/utilities/set.at \ diff --git a/tests/command/npar-binomial.sh b/tests/language/stats/npar.at old mode 100755 new mode 100644 similarity index 59% rename from tests/command/npar-binomial.sh rename to tests/language/stats/npar.at index 050c66b9..01636269 --- a/tests/command/npar-binomial.sh +++ b/tests/language/stats/npar.at @@ -1,70 +1,8 @@ -#!/bin/sh +AT_BANNER([NPAR TESTS]) -# This program tests the BINOMIAL subcommand of the NPAR TESTS 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 - - -# Tests for exact calculations -activity="create file 1" -cat < $TESTFILE -ECHO 'P < 0.5; N1/N2 < 1' . - -NEW FILE. +AT_SETUP([NPAR TESTS BINOMIAL, P < 0.5; N1/N2 < 1]) +AT_DATA([npar.sps], [dnl +SET FORMAT F8.3. DATA LIST LIST NOTABLE /x * w *. BEGIN DATA. @@ -74,18 +12,22 @@ END DATA. WEIGHT BY w. -SET FORMAT F8.3. - NPAR TESTS /BINOMIAL(0.3) = x . - - -ECHO 'P < 0.5; N1/N2 > 1' . - -NEW FILE. - - +]) +AT_CHECK([pspp -O format=csv npar.sps], [0], [dnl +Table: Binomial Test +,,Category,N,Observed Prop.,Test Prop.,Exact Sig. (1-tailed) +x,Group1,1.000,6.000,.286,.300,.551 +,Group2,2.000,15.000,.714,, +,Total,,21.000,1.000,, +]) +AT_CLEANUP + +AT_SETUP([NPAR TESTS BINOMIAL, P < 0.5; N1/N2 > 1]) +AT_DATA([npar.sps], [dnl +SET FORMAT F8.3. DATA LIST LIST NOTABLE /x (F8.0) w (F8.0). BEGIN DATA. @@ -98,12 +40,19 @@ WEIGHT BY w. NPAR TESTS /BINOMIAL(0.4) = x . +]) +AT_CHECK([pspp -O format=csv npar.sps], [0], [dnl +Table: Binomial Test +,,Category,N,Observed Prop.,Test Prop.,Exact Sig. (1-tailed) +x,Group1,1,7,.538,.400,.229 +,Group2,2,6,.462,, +,Total,,13,1.000,, +]) +AT_CLEANUP - - -ECHO 'P < 0.5; N1/N2 = 1' . - -NEW FILE. +AT_SETUP([NPAR TESTS BINOMIAL, P < 0.5; N1/N2 = 1]) +AT_DATA([npar.sps], [dnl +SET FORMAT F8.3. DATA LIST LIST NOTABLE /x (F8.0) w (F8.0). BEGIN DATA. @@ -116,10 +65,19 @@ WEIGHT BY w. NPAR TESTS /BINOMIAL(0.4) = x . +]) +AT_CHECK([pspp -O format=csv npar.sps], [0], [dnl +Table: Binomial Test +,,Category,N,Observed Prop.,Test Prop.,Exact Sig. (1-tailed) +x,Group1,1,8,.500,.400,.284 +,Group2,2,8,.500,, +,Total,,16,1.000,, +]) +AT_CLEANUP -ECHO 'P > 0.5; N1/N2 < 1' . - -NEW FILE. +AT_SETUP([NPAR TESTS BINOMIAL, P > 0.5; N1/N2 < 1]) +AT_DATA([npar.sps], [dnl +SET FORMAT F8.3. DATA LIST LIST NOTABLE /x (F8.0) w (F8.0). BEGIN DATA. @@ -132,11 +90,19 @@ WEIGHT BY w. NPAR TESTS /BINOMIAL(0.6) = x . +]) +AT_CHECK([pspp -O format=csv npar.sps], [0], [dnl +Table: Binomial Test +,,Category,N,Observed Prop.,Test Prop.,Exact Sig. (1-tailed) +x,Group1,1,11,.478,.600,.164 +,Group2,2,12,.522,, +,Total,,23,1.000,, +]) +AT_CLEANUP - -ECHO 'P > 0.5; N1/N2 > 1' . - -NEW FILE. +AT_SETUP([NPAR TESTS BINOMIAL, P > 0.5; N1/N2 > 1]) +AT_DATA([npar.sps], [dnl +SET FORMAT F8.3. DATA LIST LIST NOTABLE /x (F8.0) w (F8.0). BEGIN DATA. @@ -147,11 +113,20 @@ END DATA. WEIGHT BY w. NPAR TESTS - /BINOMIAL(0.6) = x - -ECHO 'P > 0.5; N1/N2 == 1' . + /BINOMIAL(0.6) = x. +]) +AT_CHECK([pspp -O format=csv npar.sps], [0], [dnl +Table: Binomial Test +,,Category,N,Observed Prop.,Test Prop.,Exact Sig. (1-tailed) +x,Group1,1,11,.550,.600,.404 +,Group2,2,9,.450,, +,Total,,20,1.000,, +]) +AT_CLEANUP -NEW FILE. +AT_SETUP([NPAR TESTS BINOMIAL, P > 0.5; N1/N2 = 1]) +AT_DATA([npar.sps], [dnl +SET FORMAT F8.3. DATA LIST LIST NOTABLE /x (F8.0) w (F8.0). BEGIN DATA. @@ -162,12 +137,20 @@ END DATA. WEIGHT BY w. NPAR TESTS - /BINOMIAL(0.6) = x - . - -ECHO 'P == 0.5; N1/N2 < 1' . + /BINOMIAL(0.6) = x. +]) +AT_CHECK([pspp -O format=csv npar.sps], [0], [dnl +Table: Binomial Test +,,Category,N,Observed Prop.,Test Prop.,Exact Sig. (1-tailed) +x,Group1,1,11,.500,.600,.228 +,Group2,2,11,.500,, +,Total,,22,1.000,, +]) +AT_CLEANUP -NEW FILE. +AT_SETUP([NPAR TESTS BINOMIAL, P = 0.5; N1/N2 < 1]) +AT_DATA([npar.sps], [dnl +SET FORMAT F8.3. DATA LIST LIST NOTABLE /x (F8.0) w (F8.0). BEGIN DATA. @@ -180,11 +163,19 @@ WEIGHT BY w. NPAR TESTS /BINOMIAL = x . +]) +AT_CHECK([pspp -O format=csv npar.sps], [0], [dnl +Table: Binomial Test +,,Category,N,Observed Prop.,Test Prop.,Exact Sig. (2-tailed) +x,Group1,1,8,.348,.500,.210 +,Group2,2,15,.652,, +,Total,,23,1.000,, +]) +AT_CLEANUP - -ECHO 'P == 0.5; N1/N2 > 1' . - -NEW FILE. +AT_SETUP([NPAR TESTS BINOMIAL, P = 0.5; N1/N2 > 1]) +AT_DATA([npar.sps], [dnl +SET FORMAT F8.3. DATA LIST LIST NOTABLE /x (F8.0) w (F8.0). BEGIN DATA. @@ -195,11 +186,20 @@ END DATA. WEIGHT BY w. NPAR TESTS - /BINOMIAL(0.5) = x - -ECHO 'P == 0.5; N1/N2 == 1' . + /BINOMIAL(0.5) = x. +]) +AT_CHECK([pspp -O format=csv npar.sps], [0], [dnl +Table: Binomial Test +,,Category,N,Observed Prop.,Test Prop.,Exact Sig. (2-tailed) +x,Group1,1,12,.667,.500,.238 +,Group2,2,6,.333,, +,Total,,18,1.000,, +]) +AT_CLEANUP -NEW FILE. +AT_SETUP([NPAR TESTS BINOMIAL, P = 0.5; N1/N2 = 1]) +AT_DATA([npar.sps], [dnl +SET FORMAT F8.3. DATA LIST LIST NOTABLE /x (F8.0) w (F8.0). BEGIN DATA. @@ -212,8 +212,19 @@ WEIGHT BY w. NPAR TESTS /BINOMIAL(0.5) = x . +]) +AT_CHECK([pspp -O format=csv npar.sps], [0], [dnl +Table: Binomial Test +,,Category,N,Observed Prop.,Test Prop.,Exact Sig. (2-tailed) +x,Group1,1,10,.500,.500,1.000 +,Group2,2,10,.500,, +,Total,,20,1.000,, +]) +AT_CLEANUP -ECHO 'P == 0.5; N1/N2 == 1 Cutpoint' . +AT_SETUP([NPAR TESTS BINOMIAL, P = 0.5; N1/N2 = 1 Cutpoint]) +AT_DATA([npar.sps], [dnl +SET FORMAT F8.3. DATA LIST LIST NOTABLE /x * w *. BEGIN DATA. @@ -227,8 +238,19 @@ WEIGHT BY w. NPAR TESTS /BINOMIAL(0.5) = x (10) . +]) +AT_CHECK([pspp -O format=csv npar.sps], [0], [dnl +Table: Binomial Test +,,Category,N,Observed Prop.,Test Prop.,Exact Sig. (2-tailed) +x,Group1,<= 10,10.000,.385,.500,.327 +,Group2,,16.000,.615,, +,Total,,26.000,1.000,, +]) +AT_CLEANUP -ECHO 'P == 0.5; N1/N2 == 1 Named values' . +AT_SETUP([NPAR TESTS BINOMIAL, P = 0.5; N1/N2 = 1 Named values]) +AT_DATA([npar.sps], [dnl +SET FORMAT F8.3. DATA LIST LIST NOTABLE /x * w *. BEGIN DATA. @@ -242,105 +264,13 @@ WEIGHT BY w. NPAR TESTS /BINOMIAL(0.5) = x (10, 20) . -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 -P < 0.5; N1/N2 < 1 - -Table: Binomial Test -,,Category,N,Observed Prop.,Test Prop.,Exact Sig. (1-tailed) -x,Group1,1.00,6.00,.286,.300,.551 -,Group2,2.00,15.00,.714,, -,Total,,21.00,1.000,, - -P < 0.5; N1/N2 > 1 - -Table: Binomial Test -,,Category,N,Observed Prop.,Test Prop.,Exact Sig. (1-tailed) -x,Group1,1,7,.538,.400,.229 -,Group2,2,6,.462,, -,Total,,13,1.000,, - -P < 0.5; N1/N2 = 1 - -Table: Binomial Test -,,Category,N,Observed Prop.,Test Prop.,Exact Sig. (1-tailed) -x,Group1,1,8,.500,.400,.284 -,Group2,2,8,.500,, -,Total,,16,1.000,, - -P > 0.5; N1/N2 < 1 - -Table: Binomial Test -,,Category,N,Observed Prop.,Test Prop.,Exact Sig. (1-tailed) -x,Group1,1,11,.478,.600,.164 -,Group2,2,12,.522,, -,Total,,23,1.000,, - -P > 0.5; N1/N2 > 1 - -Table: Binomial Test -,,Category,N,Observed Prop.,Test Prop.,Exact Sig. (1-tailed) -x,Group1,1,11,.550,.600,.404 -,Group2,2,9,.450,, -,Total,,20,1.000,, - -P > 0.5; N1/N2 == 1 - -Table: Binomial Test -,,Category,N,Observed Prop.,Test Prop.,Exact Sig. (1-tailed) -x,Group1,1,11,.500,.600,.228 -,Group2,2,11,.500,, -,Total,,22,1.000,, - -P == 0.5; N1/N2 < 1 - -Table: Binomial Test -,,Category,N,Observed Prop.,Test Prop.,Exact Sig. (2-tailed) -x,Group1,1,8,.348,.500,.210 -,Group2,2,15,.652,, -,Total,,23,1.000,, - -P == 0.5; N1/N2 > 1 - -Table: Binomial Test -,,Category,N,Observed Prop.,Test Prop.,Exact Sig. (2-tailed) -x,Group1,1,12,.667,.500,.238 -,Group2,2,6,.333,, -,Total,,18,1.000,, - -P == 0.5; N1/N2 == 1 - -Table: Binomial Test -,,Category,N,Observed Prop.,Test Prop.,Exact Sig. (2-tailed) -x,Group1,1,10,.500,.500,1.000 -,Group2,2,10,.500,, -,Total,,20,1.000,, - -P == 0.5; N1/N2 == 1 Cutpoint - -Table: Binomial Test -,,Category,N,Observed Prop.,Test Prop.,Exact Sig. (2-tailed) -x,Group1,<= 10,10.000,.385,.500,.327 -,Group2,,16.000,.615,, -,Total,,26.000,1.000,, - -P == 0.5; N1/N2 == 1 Named values - +]) +AT_CHECK([pspp -O format=csv npar.sps], [0], [dnl Table: Binomial Test ,,Category,N,Observed Prop.,Test Prop.,Exact Sig. (2-tailed) x,Group1,10.000,10.000,.435,.500,.678 ,Group2,20.000,13.000,.565,, ,Total,,23.000,1.000,, -EOF -if [ $? -ne 0 ] ; then fail ; fi - +]) +AT_CLEANUP -pass; -- 2.30.2