Fixed bug reporting the significance of paired value t-test.
[pspp-builds.git] / tests / expressions / valuelabel.sh
1 #!/bin/sh
2
3 # This program tests use of the VALUELABEL function in expressions.
4
5 TEMPDIR=/tmp/pspp-tst-$$
6
7 # ensure that top_srcdir and top_builddir  are absolute
8 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
9 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
10 top_srcdir=`cd $top_srcdir; pwd`
11 top_builddir=`cd $top_builddir; pwd`
12 PSPP=$top_builddir/src/ui/terminal/pspp
13
14 STAT_CONFIG_PATH=$top_srcdir/config
15 export STAT_CONFIG_PATH
16
17 LANG=C
18 export LANG
19
20 cleanup()
21 {
22      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
23         echo "NOT cleaning $TEMPDIR" 
24         return ; 
25      fi
26      cd /
27      rm -rf $TEMPDIR
28 }
29
30
31 fail()
32 {
33     echo $activity
34     echo FAILED
35     cleanup;
36     exit 1;
37 }
38
39
40 no_result()
41 {
42     echo $activity
43     echo NO RESULT;
44     cleanup;
45     exit 2;
46 }
47
48 pass()
49 {
50     cleanup;
51     exit 0;
52 }
53
54 mkdir -p $TEMPDIR
55
56 cd $TEMPDIR
57
58 activity="create program"
59 cat > $TEMPDIR/valuelabel.stat <<EOF
60 DATA LIST notable /n 1 s 2(a).
61 VALUE LABELS /n 0 'Very dissatisfied'
62                 1 'Dissatisfied'
63                 2 'Neutral'
64                 3 'Satisfied'
65                 4 'Very satisfied'.
66 VALUE LABELS /s 'a' 'Wouldn''t buy again'
67                 'b' 'Unhappy'
68                 'c' 'Bored'
69                 'd' 'Satiated'
70                 'e' 'Elated'.
71 STRING nlabel slabel(a10).
72 COMPUTE nlabel = VALUELABEL(n).
73 COMPUTE slabel = VALUELABEL(s).
74 LIST.
75 BEGIN DATA.
76
77 0a
78 1b
79 2c
80 3d
81 4e
82 5f
83 6g
84 END DATA.
85 EOF
86 if [ $? -ne 0 ] ; then no_result ; fi
87
88 activity="run program"
89 $SUPERVISOR $PSPP --testing-mode $TEMPDIR/valuelabel.stat
90 if [ $? -ne 0 ] ; then fail ; fi
91
92 activity="compare results"
93 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
94 diff -b  $TEMPDIR/pspp.list - <<EOF
95 n s     nlabel     slabel
96 - - ---------- ----------
97 .                         
98 0 a Very dissa Wouldn't b 
99 1 b Dissatisfi Unhappy    
100 2 c Neutral    Bored      
101 3 d Satisfied  Satiated   
102 4 e Very satis Elated     
103 5 f                       
104 6 g                       
105 EOF
106 if [ $? -ne 0 ] ; then fail ; fi
107
108
109
110 pass;