2103f2e96d5de3bfe24a5daed42f10792170bb27
[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], [ignore])
52 AT_CLEANUP
53
54
55
56 AT_SETUP([SET MXWARNS])
57 dnl Make sure that syntax processing stops and that
58 dnl a warning is issued when the MXWARNS figure is
59 dnl exceeded.
60 AT_DATA([set.pspp], [dnl
61 set mxwarns=2.
62 data list notable list /x (f8.2) y (f8.2).
63 begin data
64 1 2
65 3 r
66 5 x
67 q 8
68 9 9
69 3 x
70 w w
71 end data.
72
73 comment The following line should not be executed.
74 list.
75 ])
76
77 AT_CHECK([pspp -O format=csv set.pspp], [0], [dnl
78 set.pspp:5.3: warning: Data for variable y is not valid as format F: Field contents are not numeric.
79
80 set.pspp:6.3: warning: Data for variable y is not valid as format F: Field contents are not numeric.
81
82 set.pspp:7.1: warning: Data for variable x is not valid as format F: Field contents are not numeric.
83
84 note: Warnings (3) exceed limit (2).  Syntax processing will be halted.
85 ])
86
87 AT_CLEANUP
88
89
90
91
92 AT_SETUP([SET MXWARNS special case zero])
93 dnl Make sure that MXWARNS interprets zero as infinity.
94 AT_DATA([mxwarns.pspp], [dnl
95 set mxwarns=0.
96 data list notable list /x (f8.2) y (f8.2) z *.
97 begin data
98 1 2 3
99 3 r 3
100 5 x 3
101 q 8 4
102 9 9 4
103 3 x 4
104 w w 4
105 end data.
106
107 list.
108 ])
109
110 AT_CHECK([pspp -O format=csv mxwarns.pspp], [0],
111 [warning: MXWARNS set to zero.  No further warnings will be given even when potentially problematic situations are encountered.
112
113 Table: Data List
114 x,y,z
115 1.00,2.00,3.00
116 3.00,.  ,3.00
117 5.00,.  ,3.00
118 .  ,8.00,4.00
119 9.00,9.00,4.00
120 3.00,.  ,4.00
121 .  ,.  ,4.00
122 ])
123
124 AT_CLEANUP
125
126 AT_SETUP([SET macro - MEXPAND MPRINT MITERATE MNEST])
127 AT_DATA([set-macro.sps], [dnl
128 show mexpand mprint miterate mnest.
129 preserve.
130 set mexpand=off mprint=on miterate=10 mnest=11.
131 show mexpand mprint miterate mnest.
132 restore.
133 show mexpand mprint miterate mnest.
134 ])
135 AT_CHECK([pspp -O format=csv set-macro.sps], [0], [dnl
136 Table: Settings
137 MEXPAND,ON
138 MPRINT,OFF
139 MITERATE,1000
140 MNEST,50
141
142 Table: Settings
143 MEXPAND,OFF
144 MPRINT,ON
145 MITERATE,10
146 MNEST,11
147
148 Table: Settings
149 MEXPAND,ON
150 MPRINT,OFF
151 MITERATE,1000
152 MNEST,50
153 ])
154 AT_CLEANUP
155 \f
156 AT_BANNER([PRESERVE and RESTORE])
157
158 AT_SETUP([PRESERVE of SET FORMAT])
159 AT_DATA([set.pspp], [dnl
160 SHOW FORMAT.
161 PRESERVE.
162 SET FORMAT F10.0.
163 SHOW FORMAT
164 RESTORE.
165 SHOW FORMAT.
166 ])
167 AT_CHECK([pspp -O format=csv set.pspp], [0], [dnl
168 Table: Settings
169 FORMAT,F8.2
170
171 Table: Settings
172 FORMAT,F10.0
173
174 Table: Settings
175 FORMAT,F8.2
176 ])
177 AT_CLEANUP