SET: Improve error messages for SET CCx.
[pspp] / tests / language / utilities / set.at
1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
3 dnl
4 dnl This program is free software: you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation, either version 3 of the License, or
7 dnl (at your option) any later version.
8 dnl
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 dnl GNU General Public License for more details.
13 dnl
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 dnl
17 AT_BANNER([SET])
18
19 # This crashed older versions of PSPP (bug #30682).
20 AT_SETUP([SET FORMAT to invalid output format])
21 AT_DATA([set.pspp], [dnl
22 DATA LIST LIST NOTABLE /x.
23 BEGIN DATA.
24 1
25 2
26 3
27 END DATA.
28 SET FORMAT F41.
29 DESCRIPTIVES /x.
30 ])
31 AT_CHECK([pspp -O format=csv set.pspp], [1], [dnl
32 "set.pspp:7.12-7.14: error: SET: Output format F41.0 specifies width 41, but F requires a width between 1 and 40.
33     7 | SET FORMAT F41.
34       |            ^~~"
35
36 Table: Descriptive Statistics
37 ,N,Mean,Std Dev,Minimum,Maximum
38 x,3,2.00,1.00,1.00,3.00
39 Valid N (listwise),3,,,,
40 Missing N (listwise),0,,,,
41 ])
42 AT_CLEANUP
43
44
45 dnl This scenario was observed to erroneously free things twice
46 AT_SETUP([SET crash on invalid cc])
47 AT_DATA([set.pspp], [dnl
48 SET CCA='xxxx'.SHGW CCA.
49 ])
50
51 AT_CHECK([pspp -O format=csv set.pspp], [1], [dnl
52 "set.pspp:1.9-1.14: error: SET: Custom currency string `CCA' for xxxx does not contain exactly three periods or commas (or it contains both).
53     1 | SET CCA='xxxx'.SHGW CCA.
54       |         ^~~~~~"
55 ])
56 AT_CLEANUP
57
58
59
60 AT_SETUP([SET MXWARNS])
61 dnl Make sure that syntax processing stops and that
62 dnl a warning is issued when the MXWARNS figure is
63 dnl exceeded.
64 AT_DATA([set.pspp], [dnl
65 set mxwarns=2.
66 data list notable list /x (f8.2) y (f8.2).
67 begin data
68 1 2
69 3 r
70 5 x
71 q 8
72 9 9
73 3 x
74 w w
75 end data.
76
77 comment The following line should not be executed.
78 list.
79 ])
80
81 AT_CHECK([pspp -O format=csv set.pspp], [0], [dnl
82 set.pspp:5.3: warning: Data for variable y is not valid as format F: Field contents are not numeric.
83
84 set.pspp:6.3: warning: Data for variable y is not valid as format F: Field contents are not numeric.
85
86 set.pspp:7.1: warning: Data for variable x is not valid as format F: Field contents are not numeric.
87
88 note: Warnings (3) exceed limit (2).  Syntax processing will be halted.
89 ])
90
91 AT_CLEANUP
92
93
94
95
96 AT_SETUP([SET MXWARNS special case zero])
97 dnl Make sure that MXWARNS interprets zero as infinity.
98 AT_DATA([mxwarns.pspp], [dnl
99 set mxwarns=0.
100 data list notable list /x (f8.2) y (f8.2) z *.
101 begin data
102 1 2 3
103 3 r 3
104 5 x 3
105 q 8 4
106 9 9 4
107 3 x 4
108 w w 4
109 end data.
110
111 list.
112 ])
113
114 AT_CHECK([pspp -O format=csv mxwarns.pspp], [0],
115 [warning: MXWARNS set to zero.  No further warnings will be given even when potentially problematic situations are encountered.
116
117 Table: Data List
118 x,y,z
119 1.00,2.00,3.00
120 3.00,.  ,3.00
121 5.00,.  ,3.00
122 .  ,8.00,4.00
123 9.00,9.00,4.00
124 3.00,.  ,4.00
125 .  ,.  ,4.00
126 ])
127
128 AT_CLEANUP
129
130 AT_SETUP([SET macro - MEXPAND MPRINT MITERATE MNEST])
131 AT_DATA([set-macro.sps], [dnl
132 show mexpand mprint miterate mnest.
133 preserve.
134 set mexpand=off mprint=on miterate=10 mnest=11.
135 show mexpand mprint miterate mnest.
136 restore.
137 show mexpand mprint miterate mnest.
138 ])
139 AT_CHECK([pspp -O format=csv set-macro.sps], [0], [dnl
140 Table: Settings
141 MEXPAND,ON
142 MPRINT,OFF
143 MITERATE,1000
144 MNEST,50
145
146 Table: Settings
147 MEXPAND,OFF
148 MPRINT,ON
149 MITERATE,10
150 MNEST,11
151
152 Table: Settings
153 MEXPAND,ON
154 MPRINT,OFF
155 MITERATE,1000
156 MNEST,50
157 ])
158 AT_CLEANUP
159 \f
160 AT_BANNER([PRESERVE and RESTORE])
161
162 AT_SETUP([PRESERVE of SET FORMAT])
163 AT_DATA([set.pspp], [dnl
164 SHOW FORMAT.
165 PRESERVE.
166 SET FORMAT F10.0.
167 SHOW FORMAT
168 RESTORE.
169 SHOW FORMAT.
170 ])
171 AT_CHECK([pspp -O format=csv set.pspp], [0], [dnl
172 Table: Settings
173 FORMAT,F8.2
174
175 Table: Settings
176 FORMAT,F10.0
177
178 Table: Settings
179 FORMAT,F8.2
180 ])
181 AT_CLEANUP