Rewrite PSPP output engine.
[pspp-builds.git] / tests / command / npar-wilcoxon.sh
1 #!/bin/sh
2
3 # This program tests the wilcoxon subcommand of npar tests
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 # ensure that top_srcdir and top_builddir  are absolute
9 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
10 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
11 top_srcdir=`cd $top_srcdir; pwd`
12 top_builddir=`cd $top_builddir; pwd`
13
14 PSPP=$top_builddir/src/ui/terminal/pspp
15
16 STAT_CONFIG_PATH=$top_srcdir/config
17 export STAT_CONFIG_PATH
18
19 LANG=C
20 export LANG
21
22
23 cleanup()
24 {
25      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
26         echo "NOT cleaning $TEMPDIR"
27         return ; 
28      fi
29      rm -rf $TEMPDIR
30 }
31
32
33 fail()
34 {
35     echo $activity
36     echo FAILED
37     cleanup;
38     exit 1;
39 }
40
41
42 no_result()
43 {
44     echo $activity
45     echo NO RESULT;
46     cleanup;
47     exit 2;
48 }
49
50 pass()
51 {
52     cleanup;
53     exit 0;
54 }
55
56 mkdir -p $TEMPDIR
57
58 cd $TEMPDIR
59
60 activity="create program 1"
61 cat > $TESTFILE <<  EOF
62 data list notable list /foo * bar * w (f8.0).
63 begin data.
64 1.00     1.00   1
65 1.00     2.00   1
66 2.00     1.00   1
67 1.00     4.00   1
68 2.00     5.00   1
69 1.00    19.00   1
70 2.00     7.00   1
71 4.00     5.00   1
72 1.00    12.00   1
73 2.00    13.00   1
74 2.00     2.00   1
75 12.00      .00  2
76 12.00     1.00  1
77 13.00     1.00  1
78 end data
79
80 variable labels foo "first" bar "second".
81
82 weight by w.
83
84 npar test
85  /wilcoxon=foo with bar (paired)
86  /missing analysis
87  /method=exact.
88
89 EOF
90 if [ $? -ne 0 ] ; then no_result ; fi
91
92
93 activity="run program 1"
94 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
95 if [ $? -ne 0 ] ; then no_result ; fi
96
97 activity="generate results"
98 cat > $TEMPDIR/results.csv <<EOF
99 Table: Ranks
100 ,,N,Mean Rank,Sum of Ranks
101 second - first,Negative Ranks,5,8.60,43.00
102 ,Positive Ranks,8,6.00,48.00
103 ,Ties,2,,
104 ,Total,15,,
105
106 Table: Test Statistics
107 ,second - first
108 Z,-.18
109 Asymp. Sig. (2-tailed),.86
110 Exact Sig. (2-tailed),.89
111 Exact Sig. (1-tailed),.45
112 EOF
113 if [ $? -ne 0 ] ; then no_result ; fi
114
115
116 activity="compare output 1"
117 diff -c pspp.csv $TEMPDIR/results.csv
118 if [ $? -ne 0 ] ; then fail ; fi
119
120
121
122 # No weights this time. But some missing values
123 activity="create program 2"
124 cat > $TESTFILE <<  EOF
125 data list notable list /foo * bar * dummy *.
126 begin data.
127 1.00     1.00    1
128 1.00     2.00    1
129 2.00     1.00    1
130 1.00     4.00    .
131 2.00     5.00    .
132 1.00    19.00    .
133 2.00     7.00    1
134 4.00     5.00    1
135 1.00    12.00    1
136 2.00    13.00    1
137 2.00     2.00    1
138 12.00      .00   1
139 12.00      .00   1
140 34.2       .     1
141 12.00     1.00   1  
142 13.00     1.00   1
143 end data
144
145 variable labels foo "first" bar "second".
146
147 npar test
148  /wilcoxon=foo with bar (paired)
149  /missing analysis
150  /method=exact.
151
152 EOF
153 if [ $? -ne 0 ] ; then no_result ; fi
154
155
156 activity="run program 2"
157 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
158 if [ $? -ne 0 ] ; then no_result ; fi
159
160 activity="compare output 2"
161 diff pspp.csv $TEMPDIR/results.csv
162 if [ $? -ne 0 ] ; then fail ; fi
163
164
165
166 pass;