Clean up handling of median, by treating it almost like any other
[pspp-builds.git] / tests / stats / ntiles.sh
1 #! /bin/sh
2
3 # Tests the NTILE subcommand of the frequencies command
4
5 TEMPDIR=/tmp/pspp-tst-$$
6
7 # ensure that top_builddir  are absolute
8 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
9 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
10 top_builddir=`cd $top_builddir; pwd`
11 PSPP=$top_builddir/src/ui/terminal/pspp
12
13 # ensure that top_srcdir is absolute
14 top_srcdir=`cd $top_srcdir; pwd`
15
16 STAT_CONFIG_PATH=$top_srcdir/config
17 export STAT_CONFIG_PATH
18
19
20 cleanup()
21 {
22      cd /
23      rm -rf $TEMPDIR
24      :
25 }
26
27
28 fail()
29 {
30     echo $activity
31     echo FAILED
32     cleanup;
33     exit 1;
34 }
35
36
37 no_result()
38 {
39     echo $activity
40     echo NO RESULT;
41     cleanup;
42     exit 2;
43 }
44
45 pass()
46 {
47     cleanup;
48     exit 0;
49 }
50
51 mkdir -p $TEMPDIR
52
53 cd $TEMPDIR
54
55
56 i=1;
57
58 activity="create program $i"
59 cat > $TEMPDIR/prog.sps <<EOF
60 DATA LIST LIST notable /x * .
61 BEGIN DATA.
62
63
64
65
66 5
67 END DATA.
68
69 FREQUENCIES 
70         VAR=x
71         /PERCENTILES = 0 25 33.333 50 66.666 75 100
72
73 EOF
74 if [ $? -ne 0 ] ; then no_result; fi
75
76 activity="run program $i"
77 $SUPERVISOR $PSPP -o raw-ascii $TEMPDIR/prog.sps
78 if [ $? -ne 0 ] ; then no_result ; fi
79
80 activity="move output"
81 cp $TEMPDIR/pspp.list $TEMPDIR/list.ref
82 if [ $? -ne 0 ] ; then no_result ; fi
83
84 i=$[$i+1];
85
86 activity="create program $i"
87 cat > $TEMPDIR/prog.sps <<EOF
88 DATA LIST LIST notable /x * .
89 BEGIN DATA.
90
91
92
93
94 5
95 END DATA.
96
97 FREQUENCIES 
98         VAR=x
99         /NTILES = 3
100         /NTILES = 4
101         .
102 EOF
103 if [ $? -ne 0 ] ; then no_result; fi
104
105 activity="run program $i"
106 $SUPERVISOR $PSPP -o raw-ascii $TEMPDIR/prog.sps
107 if [ $? -ne 0 ] ; then no_result ; fi
108
109 activity="compare output"
110 diff $TEMPDIR/pspp.list $TEMPDIR/list.ref
111 if [ $? -ne 0 ] ; then fail; fi
112
113
114 pass;