30402bda176f04e86449e2b983a80910bc272d3c
[pspp-builds.git] / tests / command / t-test-1s.sh
1 #!/bin/sh
2
3 # This program tests that the T-TEST /TESTVAL command works OK
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 export STAT_CONFIG_PATH=$top_srcdir/config
14
15
16 cleanup()
17 {
18      rm -rf $TEMPDIR
19 }
20
21
22 fail()
23 {
24     echo $activity
25     echo FAILED
26     cleanup;
27     exit 1;
28 }
29
30
31 no_result()
32 {
33     echo $activity
34     echo NO RESULT;
35     cleanup;
36     exit 2;
37 }
38
39 pass()
40 {
41     cleanup;
42     exit 0;
43 }
44
45 mkdir -p $TEMPDIR
46
47 cd $TEMPDIR
48
49 activity="create program"
50 cat > $TESTFILE <<EOF
51 data list list /ID * ABC *.
52 begin data.
53 1 3.5
54 2 2.0
55 3 2.0
56 4 3.5
57 5 3.0
58 6 4.0
59 end data.
60
61 t-test /testval=2.0 /var=abc.
62 EOF
63 if [ $? -ne 0 ] ; then no_result ; fi
64
65
66 activity="run program"
67 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
68 if [ $? -ne 0 ] ; then no_result ; fi
69
70 activity="compare output"
71 diff -B -b $TEMPDIR/pspp.list - <<EOF
72 1.1 DATA LIST.  Reading free-form data from the command file.
73 +--------+------+
74 |Variable|Format|
75 #========#======#
76 |ID      |F8.0  |
77 |ABC     |F8.0  |
78 +--------+------+
79
80 2.1 T-TEST.  One-Sample Statistics
81 #===#=#====#==============#========#
82 #   #N|Mean|Std. Deviation|SE. Mean#
83 #===#=#====#==============#========#
84 #ABC#6|3.00|           .84|    .342#
85 #===#=#====#==============#========#
86
87 2.2 T-TEST.  One-Sample Test
88 #===#=====================================================#
89 #   #                Test Value = 2.000000                #
90 #   #-----+--+---------------+---------------+------------#
91 #   #     |  |               |               |    95%     #
92 #   #     |  |               |               +-----+------#
93 #   #  t  |df|Sig. (2-tailed)|Mean Difference|Lower| Upper#
94 #===#=====#==#===============#===============#=====#======#
95 #ABC#2.928| 5|           .033|          1.000|.1220|1.8780#
96 #===#=====#==#===============#===============#=====#======#
97 EOF
98 if [ $? -ne 0 ] ; then fail ; fi
99
100
101 pass