538d0897f7b79ca67a261745e888f04a40e4f3f4
[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 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      cd /
20      rm -rf $TEMPDIR
21 }
22
23
24 fail()
25 {
26     echo $activity
27     echo FAILED
28     cleanup;
29     exit 1;
30 }
31
32
33 no_result()
34 {
35     echo $activity
36     echo NO RESULT;
37     cleanup;
38     exit 2;
39 }
40
41 pass()
42 {
43     cleanup;
44     exit 0;
45 }
46
47 mkdir -p $TEMPDIR
48
49 cd $TEMPDIR
50
51 activity="create program"
52 cat > $TESTFILE <<EOF
53 data list free /V1 W
54 begin data.
55 1  1
56 2  1
57 3  2
58 3  1
59 4  1
60 5  1
61 6  1
62 7  1
63 8  1
64 9  1
65 10 1
66 11 1
67 12 1
68 13 1
69 14 1
70 15 1
71 16 1
72 17 1
73 18 2
74 19 1
75 20 1
76 end data.
77
78 weight by w.
79
80 examine v1 
81  /statistics=extreme(6)
82  .
83 EOF
84 if [ $? -ne 0 ] ; then no_result ; fi
85
86
87 activity="run program"
88 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
89 if [ $? -ne 0 ] ; then no_result ; fi
90
91 activity="compare results"
92 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
93 diff -b  $TEMPDIR/pspp.list - << EOF
94 1.1 EXAMINE.  Case Processing Summary
95 #==#===============================#
96 #  #             Cases             #
97 #  #----------+---------+----------#
98 #  #   Valid  | Missing |   Total  #
99 #  #--+-------+-+-------+--+-------#
100 #  # N|Percent|N|Percent| N|Percent#
101 #==#==#=======#=#=======#==#=======#
102 #V1#23|   100%|0|     0%|23|   100%#
103 #==#==#=======#=#=======#==#=======#
104 1.2 EXAMINE.  Extreme Values
105 #==========#===========#=====#
106 #          #Case Number|Value#
107 #==========#===========#=====#
108 #V1Highest1#         21|20.00#
109 #         2#         20|19.00#
110 #         3#         19|18.00#
111 #         4#         19|18.00#
112 #         5#         18|17.00#
113 #         6#         17|16.00#
114 #  --------#-----------+-----#
115 #   Lowest1#          1| 1.00#
116 #         2#          2| 2.00#
117 #         3#          4| 3.00#
118 #         4#          3| 3.00#
119 #         5#          3| 3.00#
120 #         6#          5| 4.00#
121 #==========#===========#=====#
122 EOF
123 if [ $? -ne 0 ] ; then fail ; fi
124
125 pass