Clean up output subsystem.
[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 # 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
21 cleanup()
22 {
23      cd /
24      rm -rf $TEMPDIR
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 activity="create program"
56 cat > $TESTFILE <<EOF
57 data list list /ID * A * B *.
58 begin data.
59 1 2.0 3.0
60 2 1.0 2.0
61 3 2.0 4.5
62 4 2.0 4.5
63 5 3.0 6.0
64 end data.
65
66 t-test /PAIRS a with b (PAIRED).
67 EOF
68 if [ $? -ne 0 ] ; then no_result ; fi
69
70
71 activity="run program"
72 $SUPERVISOR $PSPP -o raw-ascii $TESTFILE
73 if [ $? -ne 0 ] ; then no_result ; fi
74
75 activity="compare output"
76 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
77 diff  -b $TEMPDIR/pspp.list - <<EOF
78 1.1 DATA LIST.  Reading free-form data from INLINE.
79 +--------+------+
80 |Variable|Format|
81 #========#======#
82 |ID      |F8.0  |
83 |A       |F8.0  |
84 |B       |F8.0  |
85 +--------+------+
86 2.1 T-TEST.  Paired Sample Statistics
87 #========#====#=#==============#========#
88 #        #Mean|N|Std. Deviation|SE. Mean#
89 #========#====#=#==============#========#
90 #Pair 0 A#2.00|5|          .707|    .316#
91 #       B#4.00|5|         1.541|    .689#
92 #========#====#=#==============#========#
93 2.2 T-TEST.  Paired Samples Correlations
94 #======#=====#=#===========#====#
95 #      |     #N|Correlation|Sig.#
96 #======#=====#=#===========#====#
97 #Pair 0|A & B#5|       .918|.028#
98 #======#=====#=#===========#====#
99 2.3 T-TEST.  Paired Samples Test
100 #===========#=====================================================#======#==#===============#
101 #           #                  Paired Differences                 |      |  |               #
102 #           #-------+--------------+---------------+--------------+      |  |               #
103 #           #       |              |               |95% Confidence|      |  |               #
104 #           #       |              |               +-------+------+      |  |               #
105 #           #  Mean |Std. Deviation|Std. Error Mean| Lower | Upper|   t  |df|Sig. (2-tailed)#
106 #===========#=======#==============#===============#=======#======#======#==#===============#
107 #Pair 0A - B#-2.0000|        .93541|         .41833|-3.1615|-.8385|-4.781| 4|           .009#
108 #===========#=======#==============#===============#=======#======#======#==#===============#
109 EOF
110 if [ $? -ne 0 ] ; then fail ; fi
111
112
113 pass