Fix bug #18739.
[pspp] / tests / stats / descript-missing.sh
1 #!/bin/sh
2
3 # This program tests that the descriptives command actually works
4
5 TEMPDIR=/tmp/pspp-tst-$$
6
7 # ensure that top_builddir  are absolute
8 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
9 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
10 top_builddir=`cd $top_builddir; pwd`
11 PSPP=$top_builddir/src/ui/terminal/pspp
12
13 # ensure that top_srcdir is absolute
14 top_srcdir=`cd $top_srcdir; pwd`
15
16 STAT_CONFIG_PATH=$top_srcdir/config
17 export STAT_CONFIG_PATH
18
19 LANG=C
20 export LANG
21
22 cleanup()
23 {
24      cd /
25      rm -rf $TEMPDIR
26 }
27
28
29 fail()
30 {
31     echo $activity
32     echo FAILED
33     cleanup;
34     exit 1;
35 }
36
37
38 no_result()
39 {
40     echo $activity
41     echo NO RESULT;
42     cleanup;
43     exit 2;
44 }
45
46 pass()
47 {
48     cleanup;
49     exit 0;
50 }
51
52 mkdir -p $TEMPDIR
53
54 cd $TEMPDIR
55
56 activity="create program"
57 cat > $TEMPDIR/descript.stat <<EOF
58 title 'Test DESCRIPTIVES procedure'.
59
60 data list / V1 TO V3 1-3.
61 mis val v1 to v3 (1).
62 begin data.
63 111
64    
65  1 
66 1 1
67 112
68 123
69 234
70 end data.
71
72 descript all/stat=all/format=serial.
73 descript all/stat=all/format=serial/missing=include.
74 descript all/stat=all/format=serial/missing=listwise.
75 descript all/stat=all/format=serial/missing=listwise include.
76
77 EOF
78 if [ $? -ne 0 ] ; then no_result ; fi
79
80
81 activity="run program"
82 $SUPERVISOR $PSPP -o raw-ascii $TEMPDIR/descript.stat
83 if [ $? -ne 0 ] ; then no_result ; fi
84
85 activity="compare output"
86 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
87 diff -b $TEMPDIR/pspp.list - <<EOF
88 1.1 DATA LIST.  Reading 1 record from INLINE.
89 +--------+------+-------+------+
90 |Variable|Record|Columns|Format|
91 #========#======#=======#======#
92 |V1      |     1|  1-  1|F1.0  |
93 |V2      |     1|  2-  2|F1.0  |
94 |V3      |     1|  3-  3|F1.0  |
95 +--------+------+-------+------+
96 2.1 DESCRIPTIVES.  Valid cases = 7; cases with missing value(s) = 6.
97 +--------#-------+---------+-----+--------+-------+--------+--------+--------+--------+--------+-----+-------+-------+-----+
98 |Variable#Valid N|Missing N| Mean|S E Mean|Std Dev|Variance|Kurtosis|S E Kurt|Skewness|S E Skew|Range|Minimum|Maximum| Sum |
99 #========#=======#=========#=====#========#=======#========#========#========#========#========#=====#=======#=======#=====#
100 |V1      #      1|        6|2.000|    .   |   .   |    .   |    .   |    .   |    .   |    .   | .000|  2.000|  2.000|2.000|
101 |V2      #      2|        5|2.500|    .500|   .707|    .500|    .   |    .   |    .   |    .   |1.000|  2.000|  3.000|5.000|
102 |V3      #      3|        4|3.000|    .577|  1.000|   1.000|    .   |    .   |    .000|   1.225|2.000|  2.000|  4.000|9.000|
103 +--------#-------+---------+-----+--------+-------+--------+--------+--------+--------+--------+-----+-------+-------+-----+
104 3.1 DESCRIPTIVES.  Valid cases = 7; cases with missing value(s) = 3.
105 +--------#-------+---------+-----+--------+-------+--------+--------+--------+--------+--------+-----+-------+-------+------+
106 |Variable#Valid N|Missing N| Mean|S E Mean|Std Dev|Variance|Kurtosis|S E Kurt|Skewness|S E Skew|Range|Minimum|Maximum|  Sum |
107 #========#=======#=========#=====#========#=======#========#========#========#========#========#=====#=======#=======#======#
108 |V1      #      5|        2|1.200|    .200|   .447|    .200|   5.000|   2.000|   2.236|    .913|1.000|  1.000|  2.000| 6.000|
109 |V2      #      5|        2|1.600|    .400|   .894|    .800|    .312|   2.000|   1.258|    .913|2.000|  1.000|  3.000| 8.000|
110 |V3      #      5|        2|2.200|    .583|  1.304|   1.700|  -1.488|   2.000|    .541|    .913|3.000|  1.000|  4.000|11.000|
111 +--------#-------+---------+-----+--------+-------+--------+--------+--------+--------+--------+-----+-------+-------+------+
112 4.1 DESCRIPTIVES.  Valid cases = 1; cases with missing value(s) = 6.
113 +--------#-------+---------+-----+--------+-------+--------+--------+--------+--------+--------+-----+-------+-------+-----+
114 |Variable#Valid N|Missing N| Mean|S E Mean|Std Dev|Variance|Kurtosis|S E Kurt|Skewness|S E Skew|Range|Minimum|Maximum| Sum |
115 #========#=======#=========#=====#========#=======#========#========#========#========#========#=====#=======#=======#=====#
116 |V1      #      1|        0|2.000|    .   |   .   |    .   |    .   |    .   |    .   |    .   | .000|  2.000|  2.000|2.000|
117 |V2      #      1|        0|3.000|    .   |   .   |    .   |    .   |    .   |    .   |    .   | .000|  3.000|  3.000|3.000|
118 |V3      #      1|        0|4.000|    .   |   .   |    .   |    .   |    .   |    .   |    .   | .000|  4.000|  4.000|4.000|
119 +--------#-------+---------+-----+--------+-------+--------+--------+--------+--------+--------+-----+-------+-------+-----+
120 5.1 DESCRIPTIVES.  Valid cases = 4; cases with missing value(s) = 3.
121 +--------#-------+---------+-----+--------+-------+--------+--------+--------+--------+--------+-----+-------+-------+------+
122 |Variable#Valid N|Missing N| Mean|S E Mean|Std Dev|Variance|Kurtosis|S E Kurt|Skewness|S E Skew|Range|Minimum|Maximum|  Sum |
123 #========#=======#=========#=====#========#=======#========#========#========#========#========#=====#=======#=======#======#
124 |V1      #      4|        0|1.250|    .250|   .500|    .250|   4.000|   2.619|   2.000|   1.014|1.000|  1.000|  2.000| 5.000|
125 |V2      #      4|        0|1.750|    .479|   .957|    .917|  -1.289|   2.619|    .855|   1.014|2.000|  1.000|  3.000| 7.000|
126 |V3      #      4|        0|2.500|    .645|  1.291|   1.667|  -1.200|   2.619|    .000|   1.014|3.000|  1.000|  4.000|10.000|
127 +--------#-------+---------+-----+--------+-------+--------+--------+--------+--------+--------+-----+-------+-------+------+
128 EOF
129 if [ $? -ne 0 ] ; then fail ; fi
130
131
132 pass