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