Rewrite PSPP output engine.
[pspp-builds.git] / tests / command / npar-chisquare.sh
index 5e2e45cf2ef7015f2bf588f0172b431425c4088b..0f4b3facbe331a8f709c9fe3eb687addb8251640 100755 (executable)
@@ -26,6 +26,7 @@ cleanup()
        echo "NOT cleaning $TEMPDIR"
        return ; 
      fi
+     cd /
      rm -rf $TEMPDIR
 }
 
@@ -91,85 +92,62 @@ if [ $? -ne 0 ] ; then no_result ; fi
 
 
 activity="run program 1"
-$SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
+$SUPERVISOR $PSPP --testing-mode $TESTFILE
 if [ $? -ne 0 ] ; then no_result ; fi
 
 activity="compare output 1"
-diff $TEMPDIR/pspp.list - << EOF
-1.1 NPAR TESTS.  x
-+--------#----------+----------+--------+
-|        #Observed N|Expected N|Residual|
-+--------#----------+----------+--------+
-|    1.00#         3|      2.33|     .67|
-|    2.00#         3|      2.33|     .67|
-|    3.10#         4|      2.33|    1.67|
-|    3.20#         1|      2.33|   -1.33|
-|    4.00#         2|      2.33|    -.33|
-|    5.00#         1|      2.33|   -1.33|
-|Total   #        14|          |        |
-+--------#----------+----------+--------+
-
-1.2 NPAR TESTS.  y
-+--------#----------+----------+--------+
-|        #Observed N|Expected N|Residual|
-+--------#----------+----------+--------+
-|    1.00#         7|      3.50|    3.50|
-|    2.00#         4|      3.50|     .50|
-|    3.00#         1|      3.50|   -2.50|
-|    4.00#         2|      3.50|   -1.50|
-|Total   #        14|          |        |
-+--------#----------+----------+--------+
-
-1.3 NPAR TESTS.  Test Statistics
-+-----------#-----+-----+
-|           #  x  |  y  |
-+-----------#-----+-----+
-|Chi-Square #3.143|6.000|
-|df         #    5|    3|
-|Asymp. Sig.# .678| .112|
-+-----------#-----+-----+
-
-2.1 NPAR TESTS.  y
-+--------#----------+----------+--------+
-|        #Observed N|Expected N|Residual|
-+--------#----------+----------+--------+
-|    1.00#         7|      2.63|    4.38|
-|    2.00#         4|      3.50|     .50|
-|    3.00#         1|      4.38|   -3.38|
-|    4.00#         2|      3.50|   -1.50|
-|Total   #        14|          |        |
-+--------#----------+----------+--------+
-
-2.2 NPAR TESTS.  Test Statistics
-+-----------#------+
-|           #   y  |
-+-----------#------+
-|Chi-Square #10.610|
-|df         #     3|
-|Asymp. Sig.#  .014|
-+-----------#------+
-
-3.1 NPAR TESTS.  Frequencies
-+-----#---------------------------------------#---------------------------------------+
-|     #                   x                   #                   y                   |
-|     #--------+----------+----------+--------#--------+----------+----------+--------+
-|     #Category|Observed N|Expected N|Residual#Category|Observed N|Expected N|Residual|
-+-----#--------+----------+----------+--------#--------+----------+----------+--------+
-|1    #    2.00|         3|      3.16|    -.16#    2.00|         4|      2.21|    1.79|
-|2    #    3.00|         5|      5.26|    -.26#    3.00|         1|      3.68|   -2.68|
-|3    #    4.00|         2|      1.58|     .42#    4.00|         2|      1.11|     .89|
-|Total#        |        10|          |        #        |         7|          |        |
-+-----#--------+----------+----------+--------#--------+----------+----------+--------+
-
-3.2 NPAR TESTS.  Test Statistics
-+-----------#----+-----+
-|           #  x |  y  |
-+-----------#----+-----+
-|Chi-Square #.133|4.129|
-|df         #   2|    2|
-|Asymp. Sig.#.936| .127|
-+-----------#----+-----+
-
+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
 
@@ -198,11 +176,12 @@ if [ $? -ne 0 ] ; then no_result ; fi
 
 
 activity="run program 2"
-$SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE  > $TEMPDIR/output
+$SUPERVISOR $PSPP --testing-mode $TESTFILE  > $TEMPDIR/output
 if [ $? -eq 0 ] ; then no_result ; fi
 
 activity="compare errors 2"
-diff  $TEMPDIR/output - << EOF
+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
@@ -236,47 +215,36 @@ if [ $? -ne 0 ] ; then no_result ; fi
 
 
 activity="run program 3"
-$SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE 
+$SUPERVISOR $PSPP --testing-mode $TESTFILE 
 if [ $? -ne 0 ] ; then no_result ; fi
 
 
 activity="compare output 3"
-diff $TEMPDIR/pspp.list - <<EOF
-1.1 NPAR TESTS.  Frequencies
-+-----#---------------------------------------#---------------------------------------+
-|     #                   x                   #                   y                   |
-|     #--------+----------+----------+--------#--------+----------+----------+--------+
-|     #Category|Observed N|Expected N|Residual#Category|Observed N|Expected N|Residual|
-+-----#--------+----------+----------+--------#--------+----------+----------+--------+
-|1    #   -2.00|         0|      1.50|   -1.50#   -2.00|         0|      1.88|   -1.88|
-|2    #   -1.00|         0|      1.50|   -1.50#   -1.00|         0|      1.88|   -1.88|
-|3    #     .00|         0|      1.50|   -1.50#     .00|         0|      1.88|   -1.88|
-|4    #    1.00|         3|      1.50|    1.50#    1.00|         7|      1.88|    5.13|
-|5    #    2.00|         3|      1.50|    1.50#    2.00|         4|      1.88|    2.13|
-|6    #    3.00|         5|      1.50|    3.50#    3.00|         1|      1.88|    -.88|
-|7    #    4.00|         0|      1.50|   -1.50#    4.00|         2|      1.88|     .13|
-|8    #    5.00|         1|      1.50|    -.50#    5.00|         1|      1.88|    -.88|
-|Total#        |        12|          |        #        |        15|          |        |
-+-----#--------+----------+----------+--------#--------+----------+----------+--------+
-
-1.2 NPAR TESTS.  Test Statistics
-+-----------#------+------+
-|           #   x  |   y  |
-+-----------#------+------+
-|Chi-Square #17.333|22.867|
-|df         #     7|     7|
-|Asymp. Sig.#  .015|  .002|
-+-----------#------+------+
-
-1.3 NPAR TESTS.  Descriptive Statistics
-+-#--+-----+-----+-----+-----+
-| # N| Mean| Std.|Minim|Maxim|
-| #  |     |Devia|  um |  um |
-#=#==#=====#=====#=====#=====#
-|x#12|2.467|1.193|1.000|5.000|
-|y#15|2.067|1.335|1.000|5.000|
-+-#--+-----+-----+-----+-----+
-
+diff -c $TEMPDIR/pspp.csv - <<EOF
+Table: Frequencies
+,x,,,,y,,,
+,Category,Observed N,Expected N,Residual,Category,Observed N,Expected N,Residual
+1,-2.00,.00,1.50,-1.50,-2.00,.00,1.88,-1.88
+2,-1.00,.00,1.50,-1.50,-1.00,.00,1.88,-1.88
+3,.00,.00,1.50,-1.50,.00,.00,1.88,-1.88
+4,1.00,3.00,1.50,1.50,1.00,7.00,1.88,5.13
+5,2.00,3.00,1.50,1.50,2.00,4.00,1.88,2.13
+6,3.00,5.00,1.50,3.50,3.00,1.00,1.88,-.88
+7,4.00,.00,1.50,-1.50,4.00,2.00,1.88,.13
+8,5.00,1.00,1.50,-.50,5.00,1.00,1.88,-.88
+Total,,12.00,,,,15.00,,
+
+Table: Test Statistics
+,x,y
+Chi-Square,17.33,22.87
+df,7,7
+Asymp. Sig.,.02,.00
+
+Table: Descriptive Statistics
+,N,Mean,Std. Deviation,Minimum,Maximum
+,,,,,
+x,12.00,2.47,1.19,1.00,5.00
+y,15.00,2.07,1.33,1.00,5.00
 EOF
 if [ $? -ne 0 ] ; then fail ; fi
 
@@ -309,47 +277,36 @@ if [ $? -ne 0 ] ; then no_result ; fi
 
 
 activity="run program 4"
-$SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE 
+$SUPERVISOR $PSPP --testing-mode $TESTFILE 
 if [ $? -ne 0 ] ; then no_result ; fi
 
 
 activity="compare output 4"
-diff $TEMPDIR/pspp.list - <<EOF
-1.1 NPAR TESTS.  Frequencies
-+-----#---------------------------------------#---------------------------------------+
-|     #                   x                   #                   y                   |
-|     #--------+----------+----------+--------#--------+----------+----------+--------+
-|     #Category|Observed N|Expected N|Residual#Category|Observed N|Expected N|Residual|
-+-----#--------+----------+----------+--------#--------+----------+----------+--------+
-|1    #   -2.00|         0|      1.75|   -1.75#   -2.00|         0|      1.75|   -1.75|
-|2    #   -1.00|         0|      1.75|   -1.75#   -1.00|         0|      1.75|   -1.75|
-|3    #     .00|         0|      1.75|   -1.75#     .00|         0|      1.75|   -1.75|
-|4    #    1.00|         3|      1.75|    1.25#    1.00|         7|      1.75|    5.25|
-|5    #    2.00|         3|      1.75|    1.25#    2.00|         4|      1.75|    2.25|
-|6    #    3.00|         5|      1.75|    3.25#    3.00|         1|      1.75|    -.75|
-|7    #    4.00|         2|      1.75|     .25#    4.00|         2|      1.75|     .25|
-|8    #    5.00|         1|      1.75|    -.75#    5.00|         0|      1.75|   -1.75|
-|Total#        |        14|          |        #        |        14|          |        |
-+-----#--------+----------+----------+--------#--------+----------+----------+--------+
-
-1.2 NPAR TESTS.  Test Statistics
-+-----------#------+------+
-|           #   x  |   y  |
-+-----------#------+------+
-|Chi-Square #13.429|26.000|
-|df         #     7|     7|
-|Asymp. Sig.#  .062|  .001|
-+-----------#------+------+
-
-1.3 NPAR TESTS.  Descriptive Statistics
-+-#--+-----+-----+-----+-----+
-| # N| Mean| Std.|Minim|Maxim|
-| #  |     |Devia|  um |  um |
-#=#==#=====#=====#=====#=====#
-|x#14|2.686|1.231|1.000|5.000|
-|y#14|1.857|1.099|1.000|4.000|
-+-#--+-----+-----+-----+-----+
-
+diff -c $TEMPDIR/pspp.csv - <<EOF
+Table: Frequencies
+,x,,,,y,,,
+,Category,Observed N,Expected N,Residual,Category,Observed N,Expected N,Residual
+1,-2.00,.00,1.75,-1.75,-2.00,.00,1.75,-1.75
+2,-1.00,.00,1.75,-1.75,-1.00,.00,1.75,-1.75
+3,.00,.00,1.75,-1.75,.00,.00,1.75,-1.75
+4,1.00,3.00,1.75,1.25,1.00,7.00,1.75,5.25
+5,2.00,3.00,1.75,1.25,2.00,4.00,1.75,2.25
+6,3.00,5.00,1.75,3.25,3.00,1.00,1.75,-.75
+7,4.00,2.00,1.75,.25,4.00,2.00,1.75,.25
+8,5.00,1.00,1.75,-.75,5.00,.00,1.75,-1.75
+Total,,14.00,,,,14.00,,
+
+Table: Test Statistics
+,x,y
+Chi-Square,13.43,26.00
+df,7,7
+Asymp. Sig.,.06,.00
+
+Table: Descriptive Statistics
+,N,Mean,Std. Deviation,Minimum,Maximum
+,,,,,
+x,14.00,2.69,1.23,1.00,5.00
+y,14.00,1.86,1.10,1.00,4.00
 EOF
 if [ $? -ne 0 ] ; then fail ; fi