acd9e458a882798dbecc41cd43c5dcfff2cba243
[pspp-builds.git] / tests / command / weight.sh
1 #!/bin/sh
2
3 # This program tests the WEIGHT command
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 here=`pwd`;
9
10 # ensure that top_srcdir is absolute
11 cd $top_srcdir; top_srcdir=`pwd`
12
13 export STAT_CONFIG_PATH=$top_srcdir/config
14
15
16 cleanup()
17 {
18      rm -rf $TEMPDIR
19 }
20
21
22 fail()
23 {
24     echo $activity
25     echo FAILED
26     cleanup;
27     exit 1;
28 }
29
30
31 no_result()
32 {
33     echo $activity
34     echo NO RESULT;
35     cleanup;
36     exit 2;
37 }
38
39 pass()
40 {
41     cleanup;
42     exit 0;
43 }
44
45 mkdir -p $TEMPDIR
46
47 cd $TEMPDIR
48
49 activity="create program"
50 cat > $TESTFILE << EOF
51 data list file='$top_srcdir/tests/weighting.data'/AVAR 1-5 BVAR 6-10.
52 weight by BVAR.
53
54 descriptives AVAR /statistics all /format serial.
55 frequencies AVAR /statistics all /format condensed.
56
57 EOF
58 if [ $? -ne 0 ] ; then no_result ; fi
59
60
61 activity="run program"
62 $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii $TESTFILE
63 if [ $? -ne 0 ] ; then no_result ; fi
64
65 activity="compare results"
66 diff -B -b $TEMPDIR/pspp.list - <<EOF
67 1.1 DATA LIST.  Reading 1 record from file $top_srcdir/tests/weighting.data.
68 +--------+------+-------+------+
69 |Variable|Record|Columns|Format|
70 #========#======#=======#======#
71 |AVAR    |     1|  1-  5|F5.0  |
72 |BVAR    |     1|  6- 10|F5.0  |
73 +--------+------+-------+------+
74
75 2.1 DESCRIPTIVES.  Valid cases = 730; cases with missing value(s) = 0.
76 +--------#-------+---------+------+--------+-------+--------+--------+--------+--------+--------+------+-------+-------+---------+
77 |Variable#Valid N|Missing N| Mean |S E Mean|Std Dev|Variance|Kurtosis|S E Kurt|Skewness|S E Skew| Range|Minimum|Maximum|   Sum   |
78 #========#=======#=========#======#========#=======#========#========#========#========#========#======#=======#=======#=========#
79 |AVAR    #    730|        0|31.515|    .405| 10.937| 119.608|   2.411|    .181|   1.345|    .090|76.000| 18.000| 94.000|23006.000|
80 +--------#-------+---------+------+--------+-------+--------+--------+--------+--------+--------+------+-------+-------+---------+
81
82 3.1 FREQUENCIES.  AVAR: 
83 +--------+--------+---+---+
84 |        |        |   |Cum|
85 |  Value |  Freq  |Pct|Pct|
86 #========#========#===#===#
87 |      18|       1|  0|  0|
88 |      19|       7|  1|  1|
89 |      20|      26|  4|  5|
90 |      21|      76| 10| 15|
91 |      22|      57|  8| 23|
92 |      23|      58|  8| 31|
93 |      24|      38|  5| 36|
94 |      25|      38|  5| 41|
95 |      26|      30|  4| 45|
96 |      27|      21|  3| 48|
97 |      28|      23|  3| 51|
98 |      29|      24|  3| 55|
99 |      30|      23|  3| 58|
100 |      31|      14|  2| 60|
101 |      32|      21|  3| 63|
102 |      33|      21|  3| 65|
103 |      34|      14|  2| 67|
104 |      35|      14|  2| 69|
105 |      36|      17|  2| 72|
106 |      37|      11|  2| 73|
107 |      38|      16|  2| 75|
108 |      39|      14|  2| 77|
109 |      40|      15|  2| 79|
110 |      41|      14|  2| 81|
111 |      42|      14|  2| 83|
112 |      43|       8|  1| 84|
113 |      44|      15|  2| 86|
114 |      45|      10|  1| 88|
115 |      46|      12|  2| 89|
116 |      47|      13|  2| 91|
117 |      48|      13|  2| 93|
118 |      49|       5|  1| 94|
119 |      50|       5|  1| 94|
120 |      51|       3|  0| 95|
121 |      52|       7|  1| 96|
122 |      53|       6|  1| 96|
123 |      54|       2|  0| 97|
124 |      55|       2|  0| 97|
125 |      56|       2|  0| 97|
126 |      57|       3|  0| 98|
127 |      58|       1|  0| 98|
128 |      59|       3|  0| 98|
129 |      61|       1|  0| 98|
130 |      62|       3|  0| 99|
131 |      63|       1|  0| 99|
132 |      64|       1|  0| 99|
133 |      65|       2|  0| 99|
134 |      70|       1|  0| 99|
135 |      78|       1|  0|100|
136 |      79|       1|  0|100|
137 |      80|       1|  0|100|
138 |      94|       1|  0|100|
139 +--------+--------+---+---+
140
141 +-----------------+---------+
142 |N         Valid  |      730|
143 |          Missing|        0|
144 |Mean             |   31.515|
145 |S.E. Mean        |     .405|
146 |Median           |   28.500|
147 |Mode             |   21.000|
148 |Std Dev          |   10.937|
149 |Variance         |  119.608|
150 |Kurtosis         |    2.411|
151 |S.E. Kurt        |     .181|
152 |Skewness         |    1.345|
153 |S.E. Skew        |     .090|
154 |Range            |   76.000|
155 |Minimum          |   18.000|
156 |Maximum          |   94.000|
157 |Sum              |23006.000|
158 +-----------------+---------+
159 EOF
160 if [ $? -ne 0 ] ; then fail ; fi
161
162
163 pass;