941fcca66fabcc98bf287d02d1599b0fc69fc877
[pspp-builds.git] / tests / bugs / compute-lv.sh
1 #!/bin/sh
2
3 # This program tests for a bug involving COMPUTE and long variable names
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      cd /
20      rm -rf $TEMPDIR
21 }
22
23
24 fail()
25 {
26     echo $activity
27     echo FAILED
28     cleanup;
29     exit 1;
30 }
31
32
33 no_result()
34 {
35     echo $activity
36     echo NO RESULT;
37     cleanup;
38     exit 2;
39 }
40
41 pass()
42 {
43     cleanup;
44     exit 0;
45 }
46
47 mkdir -p $TEMPDIR
48
49 cd $TEMPDIR
50
51 activity="Create prog"
52 cat > $TESTFILE <<EOF
53 DATA LIST LIST /longVariablename * x *.
54 BEGIN DATA.
55 1 2
56 3 4
57 END DATA.
58
59
60 COMPUTE longvariableName=100-longvariablename.
61
62 LIST.
63
64 EOF
65 if [ $? -ne 0 ] ; then no_result ; fi
66
67
68 activity="run prog"
69 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
70 if [ $? -ne 0 ] ; then fail ; fi
71
72
73 activity="compare output"
74 perl -pi -e 's/^\s*$//g' pspp.list
75 diff -b pspp.list - << EOF
76 1.1 DATA LIST.  Reading free-form data from INLINE.
77 +----------------+------+
78 |    Variable    |Format|
79 #================#======#
80 |longVariablename|F8.0  |
81 |x               |F8.0  |
82 +----------------+------+
83 longVariablename        x
84 ---------------- -------- 
85            99.00     2.00
86            97.00     4.00
87 EOF
88 if [ $? -ne 0 ] ; then fail ; fi
89
90
91 pass;