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