From: Ben Pfaff Date: Tue, 5 Oct 2010 05:10:48 +0000 (-0700) Subject: T-TEST: Convert tests to Autotest framework. X-Git-Tag: v0.7.6~88 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49429d9821d57667afe29f2ead5402fa198a3a96;p=pspp-builds.git T-TEST: Convert tests to Autotest framework. --- diff --git a/tests/automake.mk b/tests/automake.mk index b3ad2b43..2eb2c4b3 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -10,16 +10,6 @@ TESTS_ENVIRONMENT += LC_ALL=C TESTS_ENVIRONMENT += EXEEXT=$(EXEEXT) dist_TESTS = \ - tests/command/t-test-1-indep-val.sh \ - tests/command/t-test-1-sample-missing-anal.sh \ - tests/command/t-test-1-sample-missing-list.sh \ - tests/command/t-test-1s.sh \ - tests/command/t-test-groups.sh \ - tests/command/t-test-indep-missing-anal.sh \ - tests/command/t-test-indep-missing-list.sh \ - tests/command/t-test-paired-missing-anal.sh \ - tests/command/t-test-paired-missing-list.sh \ - tests/command/t-test-pairs.sh \ tests/command/trimmed-mean.sh \ tests/command/tabs.sh \ tests/command/update.sh \ @@ -62,12 +52,6 @@ dist_TESTS = \ tests/bugs/random.sh \ tests/bugs/shbang.sh \ tests/bugs/signals.sh \ - tests/bugs/t-test-with-temp.sh \ - tests/bugs/t-test.sh \ - tests/bugs/t-test-alpha.sh \ - tests/bugs/t-test-alpha2.sh \ - tests/bugs/t-test-alpha3.sh \ - tests/bugs/t-test-paired.sh \ tests/bugs/temporary.sh \ tests/bugs/unwritable-dir.sh \ tests/bugs/val-labs.sh \ @@ -374,6 +358,7 @@ TESTSUITE_AT = \ tests/language/stats/reliability.at \ tests/language/stats/roc.at \ tests/language/stats/sort-cases.at \ + tests/language/stats/t-test.at \ tests/language/utilities/insert.at \ tests/language/utilities/permissions.at \ tests/language/utilities/set.at \ diff --git a/tests/bugs/t-test-alpha.sh b/tests/bugs/t-test-alpha.sh deleted file mode 100755 index a6fd5d9b..00000000 --- a/tests/bugs/t-test-alpha.sh +++ /dev/null @@ -1,116 +0,0 @@ -#!/bin/sh - -# This program tests that the T-TEST works when the independent -# variable is alpha -# BUG #11227 - -TEMPDIR=/tmp/pspp-tst-$$ -TESTFILE=$TEMPDIR/`basename $0`.sps - -# 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 - -# ensure that top_srcdir is absolute -top_srcdir=`cd $top_srcdir; pwd` - -STAT_CONFIG_PATH=$top_srcdir/config -export STAT_CONFIG_PATH - - -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 program" -cat > $TESTFILE < $TESTFILE < /dev/null -#invert v -if [ $? -eq 0 ] ; then fail ; fi - - -pass diff --git a/tests/bugs/t-test-alpha3.sh b/tests/bugs/t-test-alpha3.sh deleted file mode 100755 index ffe142dc..00000000 --- a/tests/bugs/t-test-alpha3.sh +++ /dev/null @@ -1,108 +0,0 @@ -#!/bin/sh - -# This program tests for a bug which didn't properly -# compare string values. - -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 - -cat >> $TESTFILE <> $TESTFILE < $TESTFILE < $TESTFILE < $TESTFILE < $TESTFILE <=1.514,11,9.00,3.82,1.15 -,<1.514,11,8.00,2.86,.86 - -Table: Independent Samples Test -,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,, -,,,,,,,,,95% Confidence Interval of the Difference, -,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper -DEP,Equal variances assumed,.17,.68,-.69,20.00,.50,-1.00,1.44,-4.00,2.00 -,Equal variances not assumed,,,-.69,18.54,.50,-1.00,1.44,-4.02,2.02 -EOF -if [ $? -ne 0 ] ; then fail ; fi - - -pass diff --git a/tests/command/t-test-1-sample-missing-anal.sh b/tests/command/t-test-1-sample-missing-anal.sh deleted file mode 100755 index 99fed5ca..00000000 --- a/tests/command/t-test-1-sample-missing-anal.sh +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/sh - -# This program tests that the T-TEST /TESTVAL command works OK -# when there are per analysis missing values involved. - -TEMPDIR=/tmp/pspp-tst-$$ -TESTFILE=$TEMPDIR/`basename $0`.sps - -# 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 - -# ensure that top_srcdir is absolute -top_srcdir=`cd $top_srcdir; pwd` - -STAT_CONFIG_PATH=$top_srcdir/config -export STAT_CONFIG_PATH - - -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 program 1" -cat > $TESTFILE < $TESTFILE < $TESTFILE < $TESTFILE < $TESTFILE < $TESTFILE < $TESTFILE < $TESTFILE < $TESTFILE < $TESTFILE < $TESTFILE < $TESTFILE < $TESTFILE < $TESTFILE < $TESTFILE <=1.514,11,9.00,3.82,1.15 +,<1.514,11,8.00,2.86,.86 + +Table: Independent Samples Test +,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,, +,,,,,,,,,95% Confidence Interval of the Difference, +,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper +DEP,Equal variances assumed,.17,.68,-.69,20.00,.50,-1.00,1.44,-4.00,2.00 +,Equal variances not assumed,,,-.69,18.54,.50,-1.00,1.44,-4.02,2.02 +]) +AT_CLEANUP + +AT_SETUP([T-TEST /GROUPS with per-analysis missing values]) +AT_DATA([ref.sps], [dnl +data list list /id * indep * dep1 * dep2 *. +begin data. +1 1.0 3.5 6 +2 1.0 2.0 5 +3 1.0 2.0 4 +4 2.0 3.5 3 +56 2.0 3.0 1 +end data. + +t-test /group=indep /var=dep1, dep2. +]) +AT_DATA([expout], [dnl +Table: Reading free-form data from INLINE. +Variable,Format +id,F8.0 +indep,F8.0 +dep1,F8.0 +dep2,F8.0 + +Table: Group Statistics +,indep,N,Mean,Std. Deviation,S.E. Mean +dep1,1,3,2.50,.87,.50 +,2,2,3.25,.35,.25 +dep2,1,3,5.00,1.00,.58 +,2,2,2.00,1.41,1.00 + +Table: Independent Samples Test +,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,, +,,,,,,,,,95% Confidence Interval of the Difference, +,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper +dep1,Equal variances assumed,3.75,.15,-1.12,3.00,.35,-.75,.56,-2.53,1.03 +,Equal variances not assumed,,,-1.34,2.78,.28,-.75,.56,-2.61,1.11 +dep2,Equal variances assumed,.60,.50,2.85,3.00,.07,3.00,1.15,-.67,6.67 +,Equal variances not assumed,,,2.60,1.68,.14,3.00,1.15,-2.98,8.98 +]) +AT_CHECK([pspp -o ref.csv ref.sps]) +AT_CHECK([cat ref.csv], [0], [expout]) +AT_DATA([missing.sps], [dnl +data list list /id * indep * dep1 * dep2. +begin data. +1 1.0 3.5 6 +2 1.0 2.0 5 +3 1.0 2.0 4 +4 2.0 3.5 3 +5 2.0 3.0 . +6 2.0 . 1 +7 . 3.1 5 +end data. + +* Note that if the independent variable is missing, then it's implicitly +* listwise missing. + +t-test /missing=analysis /group=indep /var=dep1 dep2. +]) +AT_CHECK([pspp -o missing.csv missing.sps]) +AT_CHECK([cat missing.csv], [0], [expout]) +AT_CLEANUP + +AT_SETUP([T-TEST /GROUPS with listwise missing values]) +AT_DATA([ref.sps], [dnl +data list list /id * indep * dep1 * dep2. +begin data. +1 1.0 3.5 6 +2 1.0 2.0 5 +3 1.0 2.0 4 +4 2.0 3.5 3 +5 2.0 3.0 2 +6 2.0 4.0 1 +end data. + +t-test /group=indep /var=dep1 dep2. +]) +AT_DATA([expout], [dnl +Table: Reading free-form data from INLINE. +Variable,Format +id,F8.0 +indep,F8.0 +dep1,F8.0 +dep2,F8.0 + +Table: Group Statistics +,indep,N,Mean,Std. Deviation,S.E. Mean +dep1,1,3,2.50,.87,.50 +,2,3,3.50,.50,.29 +dep2,1,3,5.00,1.00,.58 +,2,3,2.00,1.00,.58 + +Table: Independent Samples Test +,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,, +,,,,,,,,,95% Confidence Interval of the Difference, +,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper +dep1,Equal variances assumed,2.00,.23,-1.73,4.00,.16,-1.00,.58,-2.60,.60 +,Equal variances not assumed,,,-1.73,3.20,.18,-1.00,.58,-2.77,.77 +dep2,Equal variances assumed,.00,1.00,3.67,4.00,.02,3.00,.82,.73,5.27 +,Equal variances not assumed,,,3.67,4.00,.02,3.00,.82,.73,5.27 +]) +AT_CHECK([pspp -o ref.csv ref.sps]) +AT_CHECK([cat ref.csv], [0], [expout]) +AT_DATA([missing.sps], [dnl +data list list /id * indep * dep1 * dep2 *. +begin data. +1 1.0 3.5 6 +2 1.0 2.0 5 +3 1.0 2.0 4 +4 2.0 3.5 3 +5 2.0 3.0 2 +6 2.0 4.0 1 +7 2.0 . 0 +end data. + +t-test /missing=listwise,exclude /group=indep /var=dep1, dep2. +]) +AT_CHECK([pspp -o missing.csv missing.sps]) +AT_CHECK([cat missing.csv], [0], [expout]) +AT_CLEANUP + +AT_SETUP([T-TEST /TESTVAL]) +AT_DATA([t-test.sps], [dnl +data list list /ID * ABC *. +begin data. +1 3.5 +2 2.0 +3 2.0 +4 3.5 +5 3.0 +6 4.0 +end data. + +t-test /testval=2.0 /var=abc. +]) +AT_CHECK([pspp -o pspp.csv t-test.sps]) +AT_CHECK([cat pspp.csv], [0], [dnl +Table: Reading free-form data from INLINE. +Variable,Format +ID,F8.0 +ABC,F8.0 + +Table: One-Sample Statistics +,N,Mean,Std. Deviation,S.E. Mean +ABC,6,3.00,.84,.34 + +Table: One-Sample Test +,Test Value = 2.000000,,,,, +,,,,,95% Confidence Interval of the Difference, +,t,df,Sig. (2-tailed),Mean Difference,Lower,Upper +ABC,2.93,5,.03,1.00,.12,1.88 +]) +AT_CLEANUP + +AT_SETUP([T-TEST /TESTVAL with per-analysis missing values]) +AT_DATA([ref.sps], [dnl +data list list /id * x1 * x2. +begin data. +1 3.5 34 +2 2.0 10 +3 2.0 23 +4 3.5 98 +5 3.0 23 +67 4.0 8 +end data. + +t-test /testval=3.0 /var=x1 x2. +]) +AT_DATA([expout], [dnl +Table: Reading free-form data from INLINE. +Variable,Format +id,F8.0 +x1,F8.0 +x2,F8.0 + +Table: One-Sample Statistics +,N,Mean,Std. Deviation,S.E. Mean +x1,6,3.00,.84,.34 +x2,6,32.67,33.40,13.64 + +Table: One-Sample Test +,Test Value = 3.000000,,,,, +,,,,,95% Confidence Interval of the Difference, +,t,df,Sig. (2-tailed),Mean Difference,Lower,Upper +x1,.00,5,1.00,.00,-.88,.88 +x2,2.18,5,.08,29.67,-5.39,64.72 +]) +AT_CHECK([pspp -o ref.csv ref.sps]) +AT_CHECK([cat ref.csv], [0], [expout]) +AT_DATA([missing.sps], [dnl +data list list /id * x1 * x2. +begin data. +1 3.5 34 +2 2.0 10 +3 2.0 23 +4 3.5 98 +5 3.0 23 +6 4.0 . +7 . 8 +end data. + +t-test /missing=analysis /testval=3.0 /var=x1 x2. +]) +AT_CHECK([pspp -o missing.csv missing.sps]) +AT_CHECK([cat missing.csv], [0], [expout]) +AT_CLEANUP + +AT_SETUP([T-TEST /TESTVAL with listwise missing values]) +AT_DATA([ref.sps], [dnl +data list list /id * x1 * x2. +begin data. +1 3.5 34 +2 2.0 10 +3 2.0 23 +4 3.5 98 +5 3.0 23 +end data. + +t-test /testval=3.0 /var=x1 x2. +]) +AT_DATA([expout], [dnl +Table: Reading free-form data from INLINE. +Variable,Format +id,F8.0 +x1,F8.0 +x2,F8.0 + +Table: One-Sample Statistics +,N,Mean,Std. Deviation,S.E. Mean +x1,5,2.80,.76,.34 +x2,5,37.60,34.82,15.57 + +Table: One-Sample Test +,Test Value = 3.000000,,,,, +,,,,,95% Confidence Interval of the Difference, +,t,df,Sig. (2-tailed),Mean Difference,Lower,Upper +x1,-.59,4,.59,-.20,-1.14,.74 +x2,2.22,4,.09,34.60,-8.63,77.83 +]) +AT_CHECK([pspp -o ref.csv ref.sps]) +AT_CHECK([cat ref.csv], [0], [expout]) +AT_DATA([missing.sps], [dnl +data list list /id * x1 * x2. +begin data. +1 3.5 34 +2 2.0 10 +3 2.0 23 +4 3.5 98 +5 3.0 23 +6 4.0 99 +end data. + +MISSING VALUES x2(99). + +t-test /missing=listwise /testval=3.0 /var=x1 x2. +]) +AT_CHECK([pspp -o missing.csv missing.sps]) +AT_CHECK([cat missing.csv], [0], [expout]) +AT_CLEANUP + +AT_SETUP([T-TEST wih TEMPORARY transformation]) +AT_DATA([ref.sps], [dnl +data list list /ind * x * . +begin data. +1 3.5 +1 2.0 +1 2.0 +2 3.5 +2 3.0 +2 4.0 +end data. + +t-test /groups=ind(1,2) /var x. +]) +AT_DATA([expout], [dnl +Table: Reading free-form data from INLINE. +Variable,Format +ind,F8.0 +x,F8.0 + +Table: Group Statistics +,ind,N,Mean,Std. Deviation,S.E. Mean +x,1,3,2.50,.87,.50 +,2,3,3.50,.50,.29 + +Table: Independent Samples Test +,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,, +,,,,,,,,,95% Confidence Interval of the Difference, +,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper +x,Equal variances assumed,2.00,.23,-1.73,4.00,.16,-1.00,.58,-2.60,.60 +,Equal variances not assumed,,,-1.73,3.20,.18,-1.00,.58,-2.77,.77 +]) +AT_CHECK([pspp -o ref.csv ref.sps]) +AT_CHECK([cat ref.csv], [0], [expout]) +AT_DATA([temporary.sps], [dnl +data list list /ind * x * . +begin data. +1 3.5 +1 2.0 +1 2.0 +2 3.5 +2 3.0 +2 4.0 +2 9.0 +end data. + +TEMPORARY. +SELECT IF x < 7. + +t-test /groups=ind(1,2) /var x. +]) +AT_CHECK([pspp -o temporary.csv temporary.sps]) +AT_CHECK([cat temporary.csv], [0], [expout]) +AT_CLEANUP + +dnl Tests for a bug which caused T-TEST to crash when given invalid syntax. +AT_SETUP([T-TEST invalid syntax]) +AT_DATA([t-test.sps], [dnl +DATA LIST LIST NOTABLE /id * a * . +BEGIN DATA. +1 3.5 +2 2.0 +3 2.0 +4 3.5 +5 3.0 +6 4.0 +END DATA. + +T-TEST /testval=2.0 . +T-TEST /groups=id(3) . +]) +AT_CHECK([pspp -O format=csv t-test.sps], [1], [dnl +t-test.sps:11: error: T-TEST: One or more VARIABLES must be specified. + +t-test.sps:12: error: T-TEST: One or more VARIABLES must be specified. +]) +AT_CLEANUP + +dnl Tests for bug #11227, exhibited when the independent variable is a string. +AT_SETUP([T-TEST string variable]) +AT_DATA([t-test.sps], [dnl +data list list /ID * INDEP (a1) DEP1 * DEP2 *. +begin data. +1 'a' 1 3 +2 'a' 2 4 +3 'a' 2 4 +4 'a' 2 4 +5 'a' 3 5 +6 'b' 3 1 +7 'b' 4 2 +8 'b' 4 2 +9 'b' 4 2 +10 'b' 5 3 +11 'c' 2 2 +end data. + + +t-test /GROUPS=indep('a','b') /var=dep1 dep2. +]) +AT_CHECK([pspp -o pspp.csv t-test.sps]) +AT_CHECK([cat pspp.csv], [0], [dnl +Table: Reading free-form data from INLINE. +Variable,Format +ID,F8.0 +INDEP,A1 +DEP1,F8.0 +DEP2,F8.0 + +Table: Group Statistics +,INDEP,N,Mean,Std. Deviation,S.E. Mean +DEP1,a,5,2.00,.71,.32 +,b,5,4.00,.71,.32 +DEP2,a,5,4.00,.71,.32 +,b,5,2.00,.71,.32 + +Table: Independent Samples Test +,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,, +,,,,,,,,,95% Confidence Interval of the Difference, +,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper +DEP1,Equal variances assumed,.00,1.00,-4.47,8.00,.00,-2.00,.45,-3.03,-.97 +,Equal variances not assumed,,,-4.47,8.00,.00,-2.00,.45,-3.03,-.97 +DEP2,Equal variances assumed,.00,1.00,4.47,8.00,.00,2.00,.45,.97,3.03 +,Equal variances not assumed,,,4.47,8.00,.00,2.00,.45,.97,3.03 +]) +AT_CLEANUP + +AT_SETUP([T-TEST string variable, only one value]) +AT_DATA([t-test.sps], [dnl +data list list notable /id * indep (a1) dep1 * dep2 *. +begin data. +1 'a' 1 3 +2 'a' 2 4 +3 'a' 2 4 +4 'a' 2 4 +5 'a' 3 5 +6 'b' 3 1 +7 'b' 4 2 +8 'b' 4 2 +9 'b' 4 2 +10 'b' 5 3 +11 'c' 2 2 +end data. + + +t-test /GROUPS=indep('a') /var=dep1 dep2. +]) +AT_CHECK([pspp -O format=csv t-test.sps], [1], [dnl +"t-test.sps:17: error: T-TEST: When applying GROUPS to a string variable, two values must be specified." +]) +AT_CLEANUP + +dnl Tests for a bug which didn't properly compare string values. +AT_SETUP([T-TEST string variable comparison bug]) +AT_DATA([t-test.sps], [dnl +data list list /x * gv (a8). +begin data. +3 One +2 One +3 One +2 One +3 One +4 Two +3.5 Two +3.0 Two +end data. + +t-test group=gv('One', 'Two') + /variables = x. +]) +AT_CHECK([pspp -o pspp.csv t-test.sps]) +AT_CHECK([cat pspp.csv], [0], [dnl +Table: Reading free-form data from INLINE. +Variable,Format +x,F8.0 +gv,A8 + +Table: Group Statistics +,gv,N,Mean,Std. Deviation,S.E. Mean +x,One ,5,2.60,.55,.24 +,Two ,3,3.50,.50,.29 + +Table: Independent Samples Test +,,Levene's Test for Equality of Variances,,t-test for Equality of Means,,,,,, +,,,,,,,,,95% Confidence Interval of the Difference, +,,F,Sig.,t,df,Sig. (2-tailed),Mean Difference,Std. Error Difference,Lower,Upper +x,Equal variances assumed,1.13,.33,-2.32,6.00,.06,-.90,.38,-1.83,.03 +,Equal variances not assumed,,,-2.38,4.70,.07,-.90,.38,-1.89,.09 +]) +AT_CLEANUP +