First working version of CORRELATIONS.
[pspp-builds.git] / tests / command / correlation.sh
1 #!/bin/sh
2
3 # This program tests the CORRELATIONS command
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 # ensure that top_srcdir and top_builddir  are absolute
9 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
10 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
11 top_srcdir=`cd $top_srcdir; pwd`
12 top_builddir=`cd $top_builddir; pwd`
13
14 PSPP=$top_builddir/src/ui/terminal/pspp
15
16 STAT_CONFIG_PATH=$top_srcdir/config
17 export STAT_CONFIG_PATH
18
19 LANG=C
20 export LANG
21
22
23 cleanup()
24 {
25      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
26         echo "NOT cleaning $TEMPDIR"
27         return ; 
28      fi
29      rm -rf $TEMPDIR
30 }
31
32
33 fail()
34 {
35     echo $activity
36     echo FAILED
37     cleanup;
38     exit 1;
39 }
40
41
42 no_result()
43 {
44     echo $activity
45     echo NO RESULT;
46     cleanup;
47     exit 2;
48 }
49
50 pass()
51 {
52     cleanup;
53     exit 0;
54 }
55
56 mkdir -p $TEMPDIR
57
58 cd $TEMPDIR
59
60 activity="create program"
61 cat << EOF > $TESTFILE
62 set format = F11.3.
63 data list notable list /foo * bar * wiz * bang *.
64 begin data.
65 1   0   3   1
66 3   9 -50   5
67 3   4   3 203
68 4  -9   0  -4
69 98 78 104   2
70 3  50 -49 200
71 .   4   4   4
72 5   3   0   .
73 end data.
74
75 correlations 
76         variables = foo bar wiz bang
77         /print nosig
78         /missing = listwise
79         .
80
81 correlations 
82         variables = bar wiz
83         /print nosig
84         /missing = listwise
85         .
86
87 correlations 
88         variables = foo bar wiz bang
89         /print nosig
90         /missing = pairwise
91         .
92 EOF
93 if [ $? -ne 0 ] ; then no_result ; fi
94
95
96 activity="run program"
97 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
98 if [ $? -ne 0 ] ; then no_result ; fi
99
100 activity="compare results"
101 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
102 cp $TEMPDIR/pspp.list /tmp
103 diff -b  $TEMPDIR/pspp.list - << EOF
104 1.1 CORRELATIONS.  Correlations
105 #========================#=====#=====#=====#=====#
106 #                        #foo  |bar  |wiz  |bang #
107 #----+-------------------#-----+-----+-----+-----#
108 #foo |Pearson Correlation#1.000| .802| .890|-.308#
109 #    |Sig. (2-tailed)    #     | .055| .017| .553#
110 #----+-------------------#-----+-----+-----+-----#
111 #bar |Pearson Correlation# .802|1.000| .519| .118#
112 #    |Sig. (2-tailed)    # .055|     | .291| .824#
113 #----+-------------------#-----+-----+-----+-----#
114 #wiz |Pearson Correlation# .890| .519|1.000|-.344#
115 #    |Sig. (2-tailed)    # .017| .291|     | .505#
116 #----+-------------------#-----+-----+-----+-----#
117 #bang|Pearson Correlation#-.308| .118|-.344|1.000#
118 #    |Sig. (2-tailed)    # .553| .824| .505|     #
119 #====#===================#=====#=====#=====#=====#
120 2.1 CORRELATIONS.  Correlations
121 #=======================#=====#=====#
122 #                       #bar  |wiz  #
123 #---+-------------------#-----+-----#
124 #bar|Pearson Correlation#1.000| .497#
125 #   |Sig. (2-tailed)    #     | .210#
126 #---+-------------------#-----+-----#
127 #wiz|Pearson Correlation# .497|1.000#
128 #   |Sig. (2-tailed)    # .210|     #
129 #===#===================#=====#=====#
130 3.1 CORRELATIONS.  Correlations
131 #========================#=====#=====#=====#=====#
132 #                        #foo  |bar  |wiz  |bang #
133 #----+-------------------#-----+-----+-----+-----#
134 #foo |Pearson Correlation#1.000| .805| .883|-.308#
135 #    |Sig. (2-tailed)    #     | .029| .008| .553#
136 #    |N                  #    7|    7|    7|    6#
137 #----+-------------------#-----+-----+-----+-----#
138 #bar |Pearson Correlation# .805|1.000| .497| .164#
139 #    |Sig. (2-tailed)    # .029|     | .210| .725#
140 #    |N                  #    7|    8|    8|    7#
141 #----+-------------------#-----+-----+-----+-----#
142 #wiz |Pearson Correlation# .883| .497|1.000|-.337#
143 #    |Sig. (2-tailed)    # .008| .210|     | .460#
144 #    |N                  #    7|    8|    8|    7#
145 #----+-------------------#-----+-----+-----+-----#
146 #bang|Pearson Correlation#-.308| .164|-.337|1.000#
147 #    |Sig. (2-tailed)    # .553| .725| .460|     #
148 #    |N                  #    6|    7|    7|    7#
149 #====#===================#=====#=====#=====#=====#
150 EOF
151 if [ $? -ne 0 ] ; then fail ; fi
152
153 pass;