Make the expression code a little nicer and fix bugs found
[pspp-builds.git] / tests / command / beg-data.sh
1 #!/bin/sh
2
3 # This program tests the BEGIN DATA / END DATA commands
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/prog.sps << EOF_foobar
50 title 'Test BEGIN DATA ... END DATA'.
51
52 data list /A B 1-2.
53 list.
54 begin data.
55 12
56 34
57 56
58 78
59 90
60 end data.
61
62 data list /A B 1-2.
63 begin data.
64 09
65 87
66 65
67 43
68 21
69 end data.
70 list.
71 EOF_foobar
72 if [ $? -ne 0 ] ; then no_result ; fi
73
74
75 activity="run program"
76 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/prog.sps
77 if [ $? -ne 0 ] ; then no_result ; fi
78
79 activity="compare data"
80 diff -b -B $TEMPDIR/pspp.list - << foobar
81 1.1 DATA LIST.  Reading 1 record from the command file.
82 +--------+------+-------+------+
83 |Variable|Record|Columns|Format|
84 #========#======#=======#======#
85 |A       |     1|  1-  1|F1.0  |
86 |B       |     1|  2-  2|F1.0  |
87 +--------+------+-------+------+
88
89 A B
90 - -
91 1 2 
92 3 4 
93 5 6 
94 7 8 
95 9 0 
96
97 2.1 DATA LIST.  Reading 1 record from the command file.
98 +--------+------+-------+------+
99 |Variable|Record|Columns|Format|
100 #========#======#=======#======#
101 |A       |     1|  1-  1|F1.0  |
102 |B       |     1|  2-  2|F1.0  |
103 +--------+------+-------+------+
104
105 A B
106 - -
107 0 9 
108 8 7 
109 6 5 
110 4 3 
111 2 1 
112 foobar
113 if [ $? -ne 0 ] ; then fail ; fi
114
115
116 pass;