feb052c430c5d66b002605c70d5b44d067960086
[pspp-builds.git] / tests / command / examine-extremes.sh
1 #!/bin/sh
2
3 # This program tests  the EXTREME subcommand of the EXAMINE command.
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 # ensure that top_builddir  are absolute
9 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
10 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
11 top_builddir=`cd $top_builddir; pwd`
12 PSPP=$top_builddir/src/ui/terminal/pspp
13
14 # ensure that top_srcdir is absolute
15 top_srcdir=`cd $top_srcdir; pwd`
16
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
19
20 LANG=C
21 export LANG
22
23 cleanup()
24 {
25      cd /
26      rm -rf $TEMPDIR
27 }
28
29
30 fail()
31 {
32     echo $activity
33     echo FAILED
34     cleanup;
35     exit 1;
36 }
37
38
39 no_result()
40 {
41     echo $activity
42     echo NO RESULT;
43     cleanup;
44     exit 2;
45 }
46
47 pass()
48 {
49     cleanup;
50     exit 0;
51 }
52
53 mkdir -p $TEMPDIR
54
55 cd $TEMPDIR
56
57 activity="create program"
58 cat > $TESTFILE <<EOF
59 data list free /V1 W
60 begin data.
61 1  1
62 2  1
63 3  2
64 3  1
65 4  1
66 5  1
67 6  1
68 7  1
69 8  1
70 9  1
71 10 1
72 11 1
73 12 1
74 13 1
75 14 1
76 15 1
77 16 1
78 17 1
79 18 2
80 19 1
81 20 1
82 end data.
83
84 weight by w.
85
86 examine v1 
87  /statistics=extreme(6)
88  .
89 EOF
90 if [ $? -ne 0 ] ; then no_result ; fi
91
92
93 activity="run program"
94 $SUPERVISOR $PSPP --testing-mode $TESTFILE
95 if [ $? -ne 0 ] ; then no_result ; fi
96
97 activity="compare results"
98 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
99 diff -b  $TEMPDIR/pspp.list - << EOF
100 1.1 EXAMINE.  Case Processing Summary
101 #==#===============================#
102 #  #             Cases             #
103 #  #----------+---------+----------#
104 #  #   Valid  | Missing |   Total  #
105 #  #--+-------+-+-------+--+-------#
106 #  # N|Percent|N|Percent| N|Percent#
107 #==#==#=======#=#=======#==#=======#
108 #V1#23|   100%|0|     0%|23|   100%#
109 #==#==#=======#=#=======#==#=======#
110 1.2 EXAMINE.  Extreme Values
111 #============#===========#=====#
112 #            #Case Number|Value#
113 #============#===========#=====#
114 #V1 Highest 1#         21|20.00#
115 #           2#         20|19.00#
116 #           3#         19|18.00#
117 #           4#         19|18.00#
118 #           5#         18|17.00#
119 #           6#         17|16.00#
120 #  ----------#-----------+-----#
121 #    Lowest 1#          1| 1.00#
122 #           2#          2| 2.00#
123 #           3#          4| 3.00#
124 #           4#          3| 3.00#
125 #           5#          3| 3.00#
126 #           6#          5| 4.00#
127 #============#===========#=====#
128 EOF
129 if [ $? -ne 0 ] ; then fail ; fi
130
131 pass