e310cfb0dda67bafaad92721a4fa15f5904b6f0c
[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      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 prog"
51 cat > $TESTFILE <<EOF
52 DATA LIST LIST /longVariablename * x *.
53 BEGIN DATA.
54 1 2
55 3 4
56 END DATA.
57
58
59 COMPUTE longvariableName=100-longvariablename.
60
61 LIST.
62
63 EOF
64 if [ $? -ne 0 ] ; then no_result ; fi
65
66
67 activity="run prog"
68 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
69 if [ $? -ne 0 ] ; then fail ; fi
70
71
72 activity="compare output"
73 diff -B -b pspp.list - << EOF
74 1.1 DATA LIST.  Reading free-form data from the command file.
75 +----------------+------+
76 |    Variable    |Format|
77 #================#======#
78 |longVariablename|F8.0  |
79 |x               |F8.0  |
80 +----------------+------+
81
82 longVariablename        x
83 ---------------- -------- 
84            99.00     2.00
85            97.00     4.00
86 EOF
87 if [ $? -ne 0 ] ; then fail ; fi
88
89
90 pass;