3 # This program tests the aggregate procedure
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/aggregate.pspp
9 # ensure that top_srcdir and top_builddir are absolute
10 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
11 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
12 top_srcdir=`cd $top_srcdir; pwd`
13 top_builddir=`cd $top_builddir; pwd`
14 PSPP=$top_builddir/src/ui/terminal/pspp
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
54 activity="data create"
55 cat > aggregate.data <<EOF
69 if [ $? -ne 0 ] ; then no_result ; fi
71 activity="command skeleton create"
72 cat > agg-skel.pspp <<EOF
82 /SFGT2I = fgt.(s, '2')
83 /NFIN23 = fin(n, 2, 3)
84 /NFIN23I = fin.(n, 2, 3)
85 /SFIN23 = fin(s, '2', '3')
86 /SFIN23I = fin.(s, '2', '3')
90 /SFLT2I = flt.(s, '2')
95 /NFOUT23 = fout(n, 3, 2)
96 /NFOUT23I = fout.(n, 3, 2)
97 /SFOUT23 = fout(s, '3', '2')
98 /SFOUT23I = fout.(s, '3', '2')
126 /NNUMISSI = numiss.(n)
128 /SNUMISSI = numiss.(s)
132 /SPGT2I = pgt.(s, '2')
133 /NPIN23 = pin(n, 2, 3)
134 /NPIN23I = pin.(n, 2, 3)
135 /SPIN23 = pin(s, '2', '3')
136 /SPIN23I = pin.(s, '2', '3')
140 /SPLT2I = plt.(s, '2')
141 /NPOUT23 = pout(n, 2, 3)
142 /NPOUT23I = pout.(n, 2, 3)
143 /SPOUT23 = pout(s, '2', '3')
144 /SPOUT23I = pout.(s, '2', '3')
151 activity="expected output (itemwise missing) create"
152 cat > agg-itemwise.out <<EOF
153 G N NI NU NUI NFGT2 NFGT2I SFGT2 SFGT2I NFIN23 NFIN23I SFIN23 SFIN23I NFLT2 NFLT2I SFLT2 SFLT2I NFIRST NFIRSTI SFIRST SFIRSTI NFOUT23 NFOUT23I SFOUT23 SFOUT23I NLAST NLASTI SLAST SLASTI NMAX NMAXI SMAX SMAXI NMEAN NMEANI NMIN NMINI SMIN SMINI NN NNI SN SNI NNMISS NNMISSI SNMISS SNMISSI NNU NNUI SNU SNUI NNUMISS NNUMISSI SNUMISS SNUMISSI NPGT2 NPGT2I SPGT2 SPGT2I NPIN23 NPIN23I SPIN23 SPIN23I NPLT2 NPLT2I SPLT2 SPLT2I NPOUT23 NPOUT23I SPOUT23 SPOUT23I NSD NSDI NSUM NSUMI
154 - -------- -------- ------- ------- ----- ------ ----- ------ ------ ------- ------ ------- ----- ------ ----- ------ ------ ------- ------ ------- ------- -------- ------- -------- ----- ------ ----- ------ ---- ----- ---- ----- -------- -------- ---- ----- ---- ----- -------- -------- -------- -------- -------- -------- -------- -------- ------- ------- ------- ------- ------- -------- ------- -------- ----- ------ ----- ------ ------ ------- ------ ------- ----- ------ ----- ------ ------- -------- ------- -------- -------- -------- -------- --------
155 1 7.00 7.00 6 6 .333 .429 .333 .429 .333 .286 .333 .286 .500 .429 .500 .429 0 0 0 0 .667 .714 .667 .714 5 5 5 5 5 5 5 5 2.00 2.29 0 0 0 0 6.00 7.00 6.00 7.00 1.00 .00 1.00 .00 5 6 5 6 1 0 1 0 33.3 42.9 33.3 42.9 33.3 28.6 33.3 28.6 50.0 42.9 50.0 42.9 66.7 71.4 66.7 71.4 1.79 1.80 12.00 16.00
156 2 5.00 5.00 4 4 1.000 1.000 1.000 1.000 .000 .000 .000 .000 .000 .000 .000 .000 6 6 6 4 1.000 1.000 1.000 1.000 8 8 8 8 8 8 8 8 7.00 7.00 6 6 6 4 3.00 3.00 3.00 5.00 2.00 2.00 2.00 .00 3 3 3 4 1 1 1 0 100.0 100.0 100.0 100.0 .0 .0 .0 .0 .0 .0 .0 .0 100.0 100.0 100.0 100.0 1.00 1.00 21.00 21.00
157 3 2.00 2.00 1 1 .000 .000 .000 .000 .000 .000 .000 .000 1.000 1.000 1.000 1.000 1 1 1 1 1.000 1.000 1.000 1.000 1 1 1 1 1 1 1 1 1.00 1.00 1 1 1 1 2.00 2.00 2.00 2.00 .00 .00 .00 .00 1 1 1 1 0 0 0 0 .0 .0 .0 .0 .0 .0 .0 .0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 .00 .00 2.00 2.00
158 4 1.00 1.00 1 1 . . . 1.000 . . . .000 . . . .000 . . 4 . . . 1.000 . . 4 . . 4 . . . . 4 .00 .00 .00 1.00 1.00 1.00 1.00 .00 0 0 0 1 1 1 1 0 . . . 100.0 . . . .0 . . . .0 . . . 100.0 . . . .
161 activity="expected output (columnwise missing) create"
162 cat > agg-columnwise.out <<EOF
163 G N NI NU NUI NFGT2 NFGT2I SFGT2 SFGT2I NFIN23 NFIN23I SFIN23 SFIN23I NFLT2 NFLT2I SFLT2 SFLT2I NFIRST NFIRSTI SFIRST SFIRSTI NFOUT23 NFOUT23I SFOUT23 SFOUT23I NLAST NLASTI SLAST SLASTI NMAX NMAXI SMAX SMAXI NMEAN NMEANI NMIN NMINI SMIN SMINI NN NNI SN SNI NNMISS NNMISSI SNMISS SNMISSI NNU NNUI SNU SNUI NNUMISS NNUMISSI SNUMISS SNUMISSI NPGT2 NPGT2I SPGT2 SPGT2I NPIN23 NPIN23I SPIN23 SPIN23I NPLT2 NPLT2I SPLT2 SPLT2I NPOUT23 NPOUT23I SPOUT23 SPOUT23I NSD NSDI NSUM NSUMI
164 - -------- -------- ------- ------- ----- ------ ----- ------ ------ ------- ------ ------- ----- ------ ----- ------ ------ ------- ------ ------- ------- -------- ------- -------- ----- ------ ----- ------ ---- ----- ---- ----- -------- -------- ---- ----- ---- ----- -------- -------- -------- -------- -------- -------- -------- -------- ------- ------- ------- ------- ------- -------- ------- -------- ----- ------ ----- ------ ------ ------- ------ ------- ----- ------ ----- ------ ------- -------- ------- -------- -------- -------- -------- --------
165 1 7.00 7.00 6 6 . .429 . .429 . .286 . .286 . .429 . .429 . 0 0 . .714 . .714 . 5 5 . 5 5 . 2.29 . 0 0 6.00 7.00 6.00 7.00 1.00 .00 1.00 .00 5 6 5 6 1 0 1 0 . 42.9 . 42.9 . 28.6 . 28.6 . 42.9 . 42.9 . 71.4 . 71.4 . 1.80 . 16.00
166 2 5.00 5.00 4 4 . . . 1.000 . . . .000 . . . .000 . . 4 . . . 1.000 . . 8 . . 8 . . . . 4 3.00 3.00 3.00 5.00 2.00 2.00 2.00 .00 3 3 3 4 1 1 1 0 . . . 100.0 . . . .0 . . . .0 . . . 100.0 . . . .
167 3 2.00 2.00 1 1 .000 .000 .000 .000 .000 .000 .000 .000 1.000 1.000 1.000 1.000 1 1 1 1 1.000 1.000 1.000 1.000 1 1 1 1 1 1 1 1 1.00 1.00 1 1 1 1 2.00 2.00 2.00 2.00 .00 .00 .00 .00 1 1 1 1 0 0 0 0 .0 .0 .0 .0 .0 .0 .0 .0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 100.0 .00 .00 2.00 2.00
168 4 1.00 1.00 1 1 . . . 1.000 . . . .000 . . . .000 . . 4 . . . 1.000 . . 4 . . 4 . . . . 4 .00 .00 .00 1.00 1.00 1.00 1.00 .00 0 0 0 1 1 1 1 0 . . . 100.0 . . . .0 . . . .0 . . . 100.0 . . . .
171 for outfile in scratch active external; do
172 for sort in presorted unsorted; do
173 for missing in itemwise columnwise; do
174 name=$outfile-$sort-$missing
176 activity="create $name.pspp"
178 echo "data list notable file='aggregate.data' /G N 1-2 S 3(a) W 4."
180 echo "missing values n(4) s('4')."
181 if [ "$sort" = "presorted" ]; then
182 echo "sort cases by g."
185 if [ "$outfile" = "active" ]; then
187 elif [ "$outfile" = "external" ]; then
188 echo " outfile='aggregate.sys'"
190 echo " outfile=#AGGREGATE"
192 if [ "$sort" = "presorted" ]; then
195 if [ "$missing" = "columnwise" ]; then
196 echo " /missing=columnwise"
199 if [ "$outfile" = "external" ]; then
200 echo "get file='aggregate.sys'."
201 elif [ "$outfile" = "scratch" ]; then
202 echo "get file=#AGGREGATE."
206 if [ $? -ne 0 ] ; then no_result ; fi
208 activity="run $name.pspp"
209 $SUPERVISOR $PSPP --testing-mode -o raw-ascii -e /dev/null $name.pspp
210 if [ $? -ne 0 ] ; then no_result ; fi
212 activity="check $name output"
213 perl -pi -e 's/^\s*$//g' pspp.list agg-$missing.out
214 diff -b -w pspp.list agg-$missing.out
215 if [ $? -ne 0 ] ; then fail ; fi