New implementation of long variable names. Each variable has a
[pspp-builds.git] / tests / command / lag.sh
1 #!/bin/sh
2
3 # This program tests the LAG function
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 export STAT_CONFIG_PATH=$top_srcdir/config
14
15
16 cleanup()
17 {
18      rm -rf $TEMPDIR
19 }
20
21
22 fail()
23 {
24     echo $activity
25     echo FAILED
26     cleanup;
27     exit 1;
28 }
29
30
31 no_result()
32 {
33     echo $activity
34     echo NO RESULT;
35     cleanup;
36     exit 2;
37 }
38
39 pass()
40 {
41     cleanup;
42     exit 0;
43 }
44
45 mkdir -p $TEMPDIR
46
47 cd $TEMPDIR
48
49 activity="create program"
50 cat > $TEMPDIR/lag.stat <<EOF
51 data list /W 1.
52 begin data.
53 1
54 2
55 3
56 4
57 5
58 end data.
59
60 compute X=lag(w,1).
61 compute Y=lag(x).
62 compute Z=lag(w,2).
63 list.
64 EOF
65 if [ $? -ne 0 ] ; then no_result ; fi
66
67 activity="run program"
68 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/lag.stat
69 if [ $? -ne 0 ] ; then no_result ; fi
70
71 activity="compare result"
72 diff -b -B $TEMPDIR/pspp.list - <<EOF
73 1.1 DATA LIST.  Reading 1 record from the command file.
74 +--------+------+-------+------+
75 |Variable|Record|Columns|Format|
76 #========#======#=======#======#
77 |W       |     1|  1-  1|F1.0  |
78 +--------+------+-------+------+
79
80 W        X        Y        Z
81 - -------- -------- --------
82 1      .        .        .   
83 2     1.00      .        .   
84 3     2.00     1.00     1.00 
85 4     3.00     2.00     2.00 
86 5     4.00     3.00     3.00 
87 EOF
88 if [ $? -ne 0 ] ; then fail ; fi
89
90
91 pass;