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