693fa831c0f640430bb1d18c8dbbb08839688fe9
[pspp-builds.git] / tests / command / roc2.sh
1 #!/bin/sh
2
3 # This program tests  the ROC 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      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
26         echo "NOT cleaning $TEMPDIR" 
27         return ; 
28      fi
29      cd /
30      rm -rf $TEMPDIR
31 }
32
33
34 fail()
35 {
36     echo $activity
37     echo FAILED
38     cleanup;
39     exit 1;
40 }
41
42
43 no_result()
44 {
45     echo $activity
46     echo NO RESULT;
47     cleanup;
48     exit 2;
49 }
50
51 pass()
52 {
53     cleanup;
54     exit 0;
55 }
56
57 mkdir -p $TEMPDIR
58
59 cd $TEMPDIR
60
61 activity="create program"
62 cat > $TESTFILE <<EOF
63 set format F10.3.
64 data list notable list /x * a * comment (a20).
65 begin data.
66 0  1 ""
67 0  0 ""
68 1  1 ""
69 1  0 ""
70 2  1 ""
71 2  0 ""
72 5  1 ""
73 5  0 ""
74 10 1 ""
75 10 0 ""
76 15 1 ""
77 15 0 ""
78 20 1 ""
79 20 1 ""
80 22 0 "here and"
81 22 0 "here is the anomoly"
82 25 1 ""
83 25 0 ""
84 30 1 ""
85 30 0 ""
86 35 1 ""
87 35 0 ""
88 38 1 ""
89 38 0 ""
90 39 1 ""
91 39 0 ""
92 40 1 ""
93 40 0 ""
94 end data.
95
96 roc x by a (1)
97         /plot none
98         print = se 
99         .
100 EOF
101 if [ $? -ne 0 ] ; then no_result ; fi
102
103 activity="run program"
104 $SUPERVISOR $PSPP --testing-mode $TESTFILE
105 if [ $? -ne 0 ] ; then no_result ; fi
106
107
108 activity="compare results"
109 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
110 diff -b  $TEMPDIR/pspp.list - << EOF
111 1.2 ROC.  Area Under the Curve (x)
112 #====#==========#===============#=======================#
113 #    |          |               | Asymp. 95% Confidence #
114 #    |          |               +-----------+-----------#
115 #Area|Std. Error|Asymptotic Sig.|Lower Bound|Upper Bound#
116 #====#==========#===============#===========#===========#
117 #.490|      .111|           .927|       .307|       .673#
118 #====#==========#===============#===========#===========#
119 EOF
120 if [ $? -ne 0 ] ; then fail ; fi
121
122 pass