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