Made tests BSD diff compatible
[pspp-builds.git] / tests / command / examine-percentiles.sh
1 #!/bin/sh
2
3 # This program tests  the PERCENTILES subcommand of the EXAMINE command.
4 # In particular it tests that it behaves properly when there are only 
5 # a few cases
6
7 TEMPDIR=/tmp/pspp-tst-$$
8 TESTFILE=$TEMPDIR/`basename $0`.sps
9
10 here=`pwd`;
11
12 # ensure that top_srcdir is absolute
13 cd $top_srcdir; top_srcdir=`pwd`
14
15 STAT_CONFIG_PATH=$top_srcdir/config
16 export STAT_CONFIG_PATH
17
18
19 cleanup()
20 {
21      cd /
22      rm -rf $TEMPDIR
23 }
24
25
26 fail()
27 {
28     echo $activity
29     echo FAILED
30     cleanup;
31     exit 1;
32 }
33
34
35 no_result()
36 {
37     echo $activity
38     echo NO RESULT;
39     cleanup;
40     exit 2;
41 }
42
43 pass()
44 {
45     cleanup;
46     exit 0;
47 }
48
49 mkdir -p $TEMPDIR
50
51 cd $TEMPDIR
52
53 activity="create program"
54 cat > $TESTFILE <<EOF
55 DATA LIST LIST /X *.
56 BEGIN DATA.
57 2.00 
58 8.00 
59 5.00 
60 END DATA.
61
62 EXAMINE /x
63         /PERCENTILES=HAVERAGE.
64
65 EXAMINE /x
66         /PERCENTILES=WAVERAGE.
67
68 EXAMINE /x
69         /PERCENTILES=ROUND.
70
71 EXAMINE /x
72         /PERCENTILES=EMPIRICAL.
73
74 EXAMINE /x
75         /PERCENTILES=AEMPIRICAL.
76 EOF
77 if [ $? -ne 0 ] ; then no_result ; fi
78
79 activity="run program"
80 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
81 if [ $? -ne 0 ] ; then no_result ; fi
82
83
84 activity="compare results"
85 perl -pi -e s/^\s*\$//g $TEMPDIR/pspp.list
86 diff -b  $TEMPDIR/pspp.list - << EOF | perl -e 's/^\s*$//g'
87 1.1 DATA LIST.  Reading free-form data from the command file.
88 +--------+------+
89 |Variable|Format|
90 #========#======#
91 |X       |F8.0  |
92 +--------+------+
93
94 2.1 EXAMINE.  Case Processing Summary
95 #=#=============================#
96 # #            Cases            #
97 # #---------+---------+---------#
98 # #  Valid  | Missing |  Total  #
99 # #-+-------+-+-------+-+-------#
100 # #N|Percent|N|Percent|N|Percent#
101 #=#=#=======#=#=======#=#=======#
102 #X#3|   100%|0|     0%|3|   100%#
103 #=#=#=======#=#=======#=#=======#
104
105 2.2 EXAMINE.  Percentiles
106 #================#================================#
107 #                #             Percentiles        #
108 #                #---+---+----+----+----+----+----#
109 #                # 5 | 10| 25 | 50 | 75 | 90 | 95 #
110 #=#==============#===#===#====#====#====#====#====#
111 #X|HAverage      #.40|.80|2.00|5.00|8.00|8.00|8.00#
112 # |Tukey's Hinges#   |   |3.50|5.00|6.50|    |    #
113 #=#==============#===#===#====#====#====#====#====#
114
115 3.1 EXAMINE.  Case Processing Summary
116 #=#=============================#
117 # #            Cases            #
118 # #---------+---------+---------#
119 # #  Valid  | Missing |  Total  #
120 # #-+-------+-+-------+-+-------#
121 # #N|Percent|N|Percent|N|Percent#
122 #=#=#=======#=#=======#=#=======#
123 #X#3|   100%|0|     0%|3|   100%#
124 #=#=#=======#=#=======#=#=======#
125
126 3.2 EXAMINE.  Percentiles
127 #==================#================================#
128 #                  #             Percentiles        #
129 #                  #---+---+----+----+----+----+----#
130 #                  # 5 | 10| 25 | 50 | 75 | 90 | 95 #
131 #=#================#===#===#====#====#====#====#====#
132 #X|Weighted Average#.30|.60|1.50|3.50|5.75|7.10|7.55#
133 # |Tukey's Hinges  #   |   |3.50|5.00|6.50|    |    #
134 #=#================#===#===#====#====#====#====#====#
135
136 4.1 EXAMINE.  Case Processing Summary
137 #=#=============================#
138 # #            Cases            #
139 # #---------+---------+---------#
140 # #  Valid  | Missing |  Total  #
141 # #-+-------+-+-------+-+-------#
142 # #N|Percent|N|Percent|N|Percent#
143 #=#=#=======#=#=======#=#=======#
144 #X#3|   100%|0|     0%|3|   100%#
145 #=#=#=======#=#=======#=#=======#
146
147 4.2 EXAMINE.  Percentiles
148 #================#================================#
149 #                #             Percentiles        #
150 #                #---+---+----+----+----+----+----#
151 #                # 5 | 10| 25 | 50 | 75 | 90 | 95 #
152 #=#==============#===#===#====#====#====#====#====#
153 #X|Rounded       #.00|.00|2.00|5.00|5.00|8.00|8.00#
154 # |Tukey's Hinges#   |   |3.50|5.00|6.50|    |    #
155 #=#==============#===#===#====#====#====#====#====#
156
157 5.1 EXAMINE.  Case Processing Summary
158 #=#=============================#
159 # #            Cases            #
160 # #---------+---------+---------#
161 # #  Valid  | Missing |  Total  #
162 # #-+-------+-+-------+-+-------#
163 # #N|Percent|N|Percent|N|Percent#
164 #=#=#=======#=#=======#=#=======#
165 #X#3|   100%|0|     0%|3|   100%#
166 #=#=#=======#=#=======#=#=======#
167
168 5.2 EXAMINE.  Percentiles
169 #================#==================================#
170 #                #              Percentiles         #
171 #                #----+----+----+----+----+----+----#
172 #                #  5 | 10 | 25 | 50 | 75 | 90 | 95 #
173 #=#==============#====#====#====#====#====#====#====#
174 #X|Empirical     #2.00|2.00|2.00|5.00|8.00|8.00|8.00#
175 # |Tukey's Hinges#    |    |3.50|5.00|6.50|    |    #
176 #=#==============#====#====#====#====#====#====#====#
177
178 6.1 EXAMINE.  Case Processing Summary
179 #=#=============================#
180 # #            Cases            #
181 # #---------+---------+---------#
182 # #  Valid  | Missing |  Total  #
183 # #-+-------+-+-------+-+-------#
184 # #N|Percent|N|Percent|N|Percent#
185 #=#=#=======#=#=======#=#=======#
186 #X#3|   100%|0|     0%|3|   100%#
187 #=#=#=======#=#=======#=#=======#
188
189 6.2 EXAMINE.  Percentiles
190 #==========================#==================================#
191 #                          #              Percentiles         #
192 #                          #----+----+----+----+----+----+----#
193 #                          #  5 | 10 | 25 | 50 | 75 | 90 | 95 #
194 #=#========================#====#====#====#====#====#====#====#
195 #X|Empirical with averaging#2.00|2.00|2.00|5.00|8.00|8.00|8.00#
196 # |Tukey's Hinges          #    |    |3.50|5.00|6.50|    |    #
197 #=#========================#====#====#====#====#====#====#====#
198
199 EOF
200 if [ $? -ne 0 ] ; then fail ; fi
201
202 pass