Rewrite expression code.
[pspp-builds.git] / tests / command / print.sh
1 #!/bin/sh
2
3 # This program tests the PRINT transformation
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 # Copy this file --- it's shared with another test
50 activity="create data"
51 cp $top_srcdir/tests/data-list.data $TEMPDIR
52 if [ $? -ne 0 ] ; then no_result ; fi
53
54
55 activity="create program"
56 cat > $TEMPDIR/print.stat << foobar
57 title 'Test PRINT transformation'.
58
59 data list free table file='$TEMPDIR/data-list.data'/A B C D.
60 print outfile="foo" table/A(f8.2) '/' B(e8.2) '/' C(n10) '/' D(rbhex16) '/'.
61 print space a.
62 print outfile="foo" /a b c d.
63 list.
64
65 data list list table file='$TEMPDIR/data-list.data'/A B C D.
66 print table/A B C D.
67 list.
68
69 foobar
70 if [ $? -ne 0 ] ; then no_result ; fi
71
72
73 activity="run program"
74 $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii --testing-mode $TEMPDIR/print.stat > $TEMPDIR/errs
75 # Note   vv   --- there are errors in input.  Therefore, the  command must FAIL
76 if [ $? -eq 0 ] ; then fail ; fi
77
78 activity="compare error messages"
79 diff -w $TEMPDIR/errs - <<EOF
80 $TEMPDIR/data-list.data:1: error: (columns 1-5, field type F8.0) Field does not form a valid floating-point constant.
81 $TEMPDIR/data-list.data:1: warning: LIST: The expression on PRINT SPACE evaluated to the system-missing value.
82 $TEMPDIR/data-list.data:2: error: (columns 1-8, field type F8.0) Field does not form a valid floating-point constant.
83 $TEMPDIR/data-list.data:4: warning: LIST: The expression on PRINT SPACE evaluated to the system-missing value.
84 $TEMPDIR/data-list.data:4: error: (columns 3-12, field type F8.0) Field does not form a valid floating-point constant.
85 $TEMPDIR/data-list.data:6: warning: LIST: The expression on PRINT SPACE evaluated to the system-missing value.
86 $TEMPDIR/data-list.data:1: error: (columns 1-5, field type F8.0) Field does not form a valid floating-point constant.
87 $TEMPDIR/data-list.data:2: error: (columns 1-8, field type F8.0) Field does not form a valid floating-point constant.
88 $TEMPDIR/data-list.data:2: warning: LIST: Missing value(s) for all variables from C onward.  These will be filled with the system-missing value or blanks, as appropriate.
89 $TEMPDIR/data-list.data:3: warning: LIST: Missing value(s) for all variables from B onward.  These will be filled with the system-missing value or blanks, as appropriate.
90 $TEMPDIR/data-list.data:4: error: (columns 3-12, field type F8.0) Field does not form a valid floating-point constant.
91 $TEMPDIR/data-list.data:4: warning: LIST: Missing value(s) for all variables from C onward.  These will be filled with the system-missing value or blanks, as appropriate.
92 $TEMPDIR/data-list.data:5: warning: LIST: Missing value(s) for all variables from C onward.  These will be filled with the system-missing value or blanks, as appropriate.
93 $TEMPDIR/data-list.data:6: warning: LIST: Missing value(s) for all variables from B onward.  These will be filled with the system-missing value or blanks, as appropriate.
94 EOF
95 if [ $? -ne 0 ] ; then fail ; fi
96
97
98 activity="compare output"
99 diff -b -B $TEMPDIR/pspp.list - << EOF
100 1.1 DATA LIST.  Reading free-form data from file $TEMPDIR/data-list.data.
101 +--------+------+
102 |Variable|Format|
103 #========#======#
104 |A       |F8.0  |
105 |B       |F8.0  |
106 |C       |F8.0  |
107 |D       |F8.0  |
108 +--------+------+
109
110 2.1 PRINT.  Writing 1 record(s) to file foo.
111 +--------+------+-------+-------+
112 |Variable|Record|Columns| Format|
113 #========#======#=======#=======#
114 |A       |     1|  1-  8|F8.2   |
115 |"/"     |     1|  9-  9|A1     |
116 |B       |     1| 10- 17|E8.2   |
117 |"/"     |     1| 18- 18|A1     |
118 |C       |     1| 19- 28|N10.0  |
119 |"/"     |     1| 29- 29|A1     |
120 |D       |     1| 30- 45|RBHEX16|
121 |"/"     |     1| 46- 46|A1     |
122 +--------+------+-------+-------+
123
124
125        A        B        C        D
126 -------- -------- -------- --------
127      .       2.00     3.00     4.00 
128
129      .       6.00     7.00     8.00 
130
131      .      10.00    11.00    12.00 
132
133 3.1 DATA LIST.  Reading free-form data from file $TEMPDIR/data-list.data.
134 +--------+------+
135 |Variable|Format|
136 #========#======#
137 |A       |F8.0  |
138 |B       |F8.0  |
139 |C       |F8.0  |
140 |D       |F8.0  |
141 +--------+------+
142
143 4.1 PRINT.  Writing 1 record(s) to the listing file.
144 +--------+------+-------+------+
145 |Variable|Record|Columns|Format|
146 #========#======#=======#======#
147 |A       |     1|  1-  8|F8.2  |
148 |B       |     1| 10- 17|F8.2  |
149 |C       |     1| 19- 26|F8.2  |
150 |D       |     1| 28- 35|F8.2  |
151 +--------+------+-------+------+
152      .       2.00     3.00     4.00 
153
154        A        B        C        D
155 -------- -------- -------- --------
156      .       2.00     3.00     4.00 
157      .       6.00      .        .   
158      .       6.00      .        .   
159     7.00      .        .        .   
160     7.00      .        .        .   
161     8.00      .        .        .   
162     8.00      .        .        .   
163    10.00    11.00      .        .   
164    10.00    11.00      .        .   
165    12.00      .        .        .   
166    12.00      .        .        .   
167
168 EOF
169 if [ $? -ne 0 ] ; then fail ; fi
170
171
172 activity="compare print out"
173 diff $TEMPDIR/foo - << EOF
174      .  /2.00E+00/0000000003/0000000000001040/
175      .       2.00     3.00     4.00 
176      .  /6.00E+00/0000000007/0000000000002040/
177      .       6.00     7.00     8.00 
178      .  /1.00E+01/0000000011/0000000000002840/
179      .      10.00    11.00    12.00 
180 EOF
181 if [ $? -ne 0 ] ; then fail ; fi
182
183 pass;