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