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