382e2a036594c327b3700e3892805927872c3395
[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 remark EOF
53 ----------------------------------------------------------------------
54 First we show that we can input data with BEGIN DATA/END DATA after
55 a procedure.
56 ----------------------------------------------------------------------
57 EOF
58 data list /A B 1-2.
59 list.
60 begin data.
61 12
62 34
63 56
64 78
65 90
66 end data.
67
68 remark EOF
69 ----------------------------------------------------------------------
70 Next we show that BEGIN DATA/END DATA work fine on their own as well.
71 ----------------------------------------------------------------------
72 EOF
73 data list /A B 1-2.
74 begin data.
75 09
76 87
77 65
78 43
79 21
80 end data.
81 list.
82 EOF_foobar
83 if [ $? -ne 0 ] ; then no_result ; fi
84
85
86 activity="run program"
87 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/prog.sps
88 if [ $? -ne 0 ] ; then no_result ; fi
89
90 activity="compare data"
91 diff -b -B $TEMPDIR/pspp.list - << foobar
92 ----------------------------------------------------------------------
93 First we show that we can input data with BEGIN DATA/END DATA after
94 a procedure.
95 ----------------------------------------------------------------------
96
97 1.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 1 2 
108 3 4 
109 5 6 
110 7 8 
111 9 0 
112
113 ----------------------------------------------------------------------
114 Next we show that BEGIN DATA/END DATA work fine on their own as well.
115 ----------------------------------------------------------------------
116
117 2.1 DATA LIST.  Reading 1 record from the command file.
118 +--------+------+-------+------+
119 |Variable|Record|Columns|Format|
120 #========#======#=======#======#
121 |A       |     1|  1-  1|F1.0  |
122 |B       |     1|  2-  2|F1.0  |
123 +--------+------+-------+------+
124
125 A B
126 - -
127 0 9 
128 8 7 
129 6 5 
130 4 3 
131 2 1 
132 foobar
133 if [ $? -ne 0 ] ; then fail ; fi
134
135
136 pass;