Fix use of "export" to work with traditional shells.
[pspp-builds.git] / tests / command / t-test-pairs.sh
1 #!/bin/sh
2
3 # This program tests that the T-TEST /PAIRS 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 STAT_CONFIG_PATH=$top_srcdir/config
14 export STAT_CONFIG_PATH
15
16
17 cleanup()
18 {
19      rm -rf $TEMPDIR
20 }
21
22
23 fail()
24 {
25     echo $activity
26     echo FAILED
27     cleanup;
28     exit 1;
29 }
30
31
32 no_result()
33 {
34     echo $activity
35     echo NO RESULT;
36     cleanup;
37     exit 2;
38 }
39
40 pass()
41 {
42     cleanup;
43     exit 0;
44 }
45
46 mkdir -p $TEMPDIR
47
48 cd $TEMPDIR
49
50 activity="create program"
51 cat > $TESTFILE <<EOF
52 data list list /ID * A * B *.
53 begin data.
54 1 2.0 3.0
55 2 1.0 2.0
56 3 2.0 4.5
57 4 2.0 4.5
58 5 3.0 6.0
59 end data.
60
61 t-test /PAIRS a with b (PAIRED).
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 |A       |F8.0  |
78 |B       |F8.0  |
79 +--------+------+
80
81 2.1 T-TEST.  Paired Sample Statistics
82 #========#====#=#==============#========#
83 #        #Mean|N|Std. Deviation|SE. Mean#
84 #========#====#=#==============#========#
85 #Pair 0 A#2.00|5|          .707|    .316#
86 #       B#4.00|5|         1.541|    .689#
87 #========#====#=#==============#========#
88
89 2.2 T-TEST.  Paired Samples Correlations
90 #======#=====#=#===========#====#
91 #      |     #N|Correlation|Sig.#
92 #======#=====#=#===========#====#
93 #Pair 0|A & B#5|       .918|.028#
94 #======#=====#=#===========#====#
95
96 2.3 T-TEST.  Paired Samples Test
97 #===========#=====================================================#======#==#===============#
98 #           #                  Paired Differences                 |      |  |               #
99 #           #-------+--------------+---------------+--------------+      |  |               #
100 #           #       |              |               |     95%      |      |  |               #
101 #           #       |              |               +-------+------+      |  |               #
102 #           #  Mean |Std. Deviation|Std. Error Mean| Lower | Upper|   t  |df|Sig. (2-tailed)#
103 #===========#=======#==============#===============#=======#======#======#==#===============#
104 #Pair 0A - B#-2.0000|        .93541|         .41833|-3.1615|-.8385|-4.781| 4|           .009#
105 #===========#=======#==============#===============#=======#======#======#==#===============#
106 EOF
107 if [ $? -ne 0 ] ; then fail ; fi
108
109
110 pass