File: insert.at

package info (click to toggle)
pspp 2.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 66,676 kB
  • sloc: ansic: 267,210; xml: 18,446; sh: 5,534; python: 2,881; makefile: 125; perl: 64
file content (276 lines) | stat: -rw-r--r-- 6,640 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
dnl PSPP - a program for statistical analysis.
dnl Copyright (C) 2017 Free Software Foundation, Inc.
dnl
dnl This program is free software: you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation, either version 3 of the License, or
dnl (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
dnl
AT_BANNER([INSERT])

dnl Create a file "batch.sps" that is valid syntax only in batch mode.
m4_define([CREATE_BATCH_SPS],
  [AT_DATA([batch.sps], [dnl
input program
loop #i = 1 to 5
+  compute z = #i
+  end case
end loop
end file
end input program
])])

AT_SETUP([INSERT SYNTAX=INTERACTIVE])
CREATE_BATCH_SPS
AT_DATA([insert.sps], [dnl
INSERT
  FILE='batch.sps'
  SYNTAX=interactive.
LIST.
])
AT_CHECK([pspp -o pspp.csv insert.sps], [1], [dnl
batch.sps:2.1-2.4: error: INPUT PROGRAM: Syntax error expecting end of command.
    2 | loop #i = 1 to 5
      | ^~~~
batch.sps:3.4-3.10: error: COMPUTE: COMPUTE is allowed only after the active dataset has been defined or inside INPUT PROGRAM.
    3 | +  compute z = #i
      |    ^~~~~~~
batch.sps:4.4-4.11: error: END CASE: END CASE is allowed only inside INPUT PROGRAM.
    4 | +  end case
      |    ^~~~~~~~
insert.sps:4.1-4.4: error: LIST: LIST is allowed only after the active dataset has been defined.
    4 | LIST.
      | ^~~~
])
AT_CLEANUP

AT_SETUP([INSERT SYNTAX=BATCH])
CREATE_BATCH_SPS
AT_DATA([insert.sps], [dnl
INSERT
  FILE='batch.sps'
  SYNTAX=BATCH.
LIST.
])
AT_CHECK([pspp -o pspp.csv insert.sps])
AT_CHECK([cat pspp.csv], [0], [dnl
Table: Data List
z
1.00
2.00
3.00
4.00
5.00
])
AT_CLEANUP

AT_SETUP([INSERT CD=NO])
AT_DATA([insert.sps], [INSERT FILE='Dir1/foo.sps'.
LIST.
])
mkdir Dir1
AT_DATA([Dir1/foo.sps], [INSERT FILE='bar.sps' CD=NO.
])
AT_DATA([Dir1/bar.sps],
  [DATA LIST LIST /x *.
BEGIN DATA.
1
2
3
END DATA.
])
AT_CHECK([pspp -o pspp.csv insert.sps], [1], [dnl
Dir1/foo.sps:1: error: INSERT: Can't find `bar.sps' in include file search path.
insert.sps:2.1-2.4: error: LIST: LIST is allowed only after the active dataset has been defined.
    2 | LIST.
      | ^~~~
])
AT_CLEANUP

AT_SETUP([INSERT CD=YES])
AT_DATA([insert.sps], [INSERT FILE='Dir1/foo.sps' CD=YES.
LIST.
])
mkdir Dir1
AT_DATA([Dir1/foo.sps], [INSERT FILE='bar.sps'.
])
AT_DATA([Dir1/bar.sps],
  [DATA LIST LIST /x *.
BEGIN DATA.
1
2
3
END DATA.
])
AT_CHECK([pspp -o pspp.csv insert.sps])
AT_CHECK([cat pspp.csv], [0], [dnl
Table: Reading free-form data from INLINE.
Variable,Format
x,F8.0

Table: Data List
x
1.00
2.00
3.00
])
AT_CLEANUP

m4_define([CREATE_ERROR_SPS],
  [AT_DATA([error.sps], [dnl
DATA LIST NOTABLE LIST /x *.
BEGIN DATA.
1
2
3
END DATA.

* The following line is erroneous

DISPLAY AKSDJ.
LIST.
])])

AT_SETUP([INSERT ERROR=STOP])
CREATE_ERROR_SPS
AT_DATA([insert.sps], [INSERT FILE='error.sps' ERROR=STOP.
])
AT_CHECK([pspp -o pspp.csv insert.sps], [1], [dnl
error.sps:10.9-10.13: error: DISPLAY: AKSDJ is not a variable name.
   10 | DISPLAY AKSDJ.
      |         ^~~~~
warning: Error encountered while ERROR=STOP is effective.
])
AT_CLEANUP

AT_SETUP([INSERT ERROR=CONTINUE])
CREATE_ERROR_SPS
AT_DATA([insert.sps], [INSERT FILE='error.sps' ERROR=CONTINUE.
])
AT_CHECK([pspp -o pspp.csv insert.sps], [1], [dnl
error.sps:10.9-10.13: error: DISPLAY: AKSDJ is not a variable name.
   10 | DISPLAY AKSDJ.
      |         ^~~~~
])
AT_CHECK([cat pspp.csv], [0], [dnl
"error.sps:10.9-10.13: error: DISPLAY: AKSDJ is not a variable name.
   10 | DISPLAY AKSDJ.
      |         ^~~~~"

Table: Data List
x
1.00
2.00
3.00
])
AT_CLEANUP

dnl Test for regression against bug #24569 in which PSPP crashed
dnl upon attempt to insert a nonexistent file.
AT_SETUP([INSERT nonexistent file])
AT_DATA([insert.sps], [dnl
INSERT
  FILE='nonexistent'
  ERROR=CONTINUE.
  .

LIST.
])
AT_CHECK([pspp -O format=csv insert.sps], [1], [dnl
insert.sps:2: error: INSERT: Can't find `nonexistent' in include file search path.

"insert.sps:6.1-6.4: error: LIST: LIST is allowed only after the active dataset has been defined.
    6 | LIST.
      | ^~~~"
])
AT_CLEANUP


dnl A test to check the INCLUDE command complete with the
dnl syntax and function of the ENCODING subcommand.
AT_SETUP([INCLUDE full check])
AT_DATA([two-utf8.sps], [dnl
echo 'Äpfelfölfaß'.
])

AT_DATA([include.sps], [dnl
echo 'ONE'.

include FILE='two-latin1.sps' ENCODING='ISO_8859-1'.
])

AT_CHECK([iconv -f UTF-8 -t iso-8859-1 two-utf8.sps > two-latin1.sps], [0], [])

AT_CHECK([pspp -O format=csv include.sps], [0], [dnl
ONE

Äpfelfölfaß
])
AT_CLEANUP




dnl Test for a bug where insert crashed on an unterminated string input
AT_SETUP([INSERT unterminated string])

AT_DATA([insert.sps], [INSERT FILE=7bar.sps' CD=NO.
])

AT_CHECK([pspp -O format=csv insert.sps], [1], [ignore])

AT_CLEANUP

AT_SETUP([INSERT syntax errors])
AT_KEYWORDS([INCLUDE])
: >inner.sps
AT_DATA([insert.sps], [dnl
INSERT **.
INSERT 'nonexistent.sps'.
INSERT 'inner.sps' ENCODING=**.
INSERT 'inner.sps' SYNTAX=**.
INSERT 'inner.sps' CD=**.
INSERT 'inner.sps' ERROR=**.
INSERT 'inner.sps' **.
INCLUDE 'inner.sps' **.
])
AT_CHECK([pspp -O format=csv insert.sps], [1], [dnl
"insert.sps:1.8-1.9: error: INSERT: Syntax error expecting string.
    1 | INSERT **.
      |        ^~"

insert.sps:2: error: INSERT: Can't find `nonexistent.sps' in include file search path.

"insert.sps:3.29-3.30: error: INSERT: Syntax error expecting string.
    3 | INSERT 'inner.sps' ENCODING=**.
      |                             ^~"

"insert.sps:4.27-4.28: error: INSERT: Syntax error expecting BATCH, INTERACTIVE, or AUTO.
    4 | INSERT 'inner.sps' SYNTAX=**.
      |                           ^~"

"insert.sps:5.23-5.24: error: INSERT: Syntax error expecting YES or NO.
    5 | INSERT 'inner.sps' CD=**.
      |                       ^~"

"insert.sps:6.26-6.27: error: INSERT: Syntax error expecting CONTINUE or STOP.
    6 | INSERT 'inner.sps' ERROR=**.
      |                          ^~"

"insert.sps:7.20-7.21: error: INSERT: Syntax error expecting ENCODING, SYNTAX, CD, or ERROR.
    7 | INSERT 'inner.sps' **.
      |                    ^~"

"insert.sps:8.21-8.22: error: INCLUDE: Syntax error expecting ENCODING.
    8 | INCLUDE 'inner.sps' **.
      |                     ^~"
])
AT_CLEANUP