Add copyright and licence notices to files which lack them.
[pspp] / tests / language / data-io / list.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 AT_BANNER([LIST])
17
18 AT_SETUP([LIST plain cases])
19 AT_DATA([data.txt], [dnl
20    18    1
21    19    7
22    20   26
23    21   76
24    22   57
25    23   58
26    24   38
27    25   38
28    26   30
29    27   21
30    28   23
31 ])
32 AT_DATA([list.sps], [dnl
33 DATA LIST FILE='data.txt'/avar 1-5 bvar 6-10.
34 WEIGHT BY bvar.
35 LIST.
36 ])
37 AT_CHECK([pspp -o pspp.csv list.sps])
38 AT_CHECK([cat pspp.csv], [0], [dnl
39 Table: Reading 1 record from `data.txt'.
40 Variable,Record,Columns,Format
41 avar,1,1-  5,F5.0
42 bvar,1,6- 10,F5.0
43
44 Table: Data List
45 avar,bvar
46 18,1
47 19,7
48 20,26
49 21,76
50 22,57
51 23,58
52 24,38
53 25,38
54 26,30
55 27,21
56 28,23
57 ])
58 AT_CLEANUP
59
60 AT_SETUP([LIST numbered cases])
61 AT_DATA([data.txt], [dnl
62    18    1
63    19    7
64    20   26
65    21   76
66    22   57
67    23   58
68    24   38
69    25   38
70    26   30
71    27   21
72    28   23
73 ])
74 AT_DATA([list.sps], [dnl
75 DATA LIST FILE='data.txt'/avar 1-5 bvar 6-10.
76 WEIGHT BY bvar.
77 LIST/FORMAT NUMBERED.
78 ])
79 AT_CHECK([pspp -o pspp.csv list.sps])
80 AT_CHECK([cat pspp.csv], [0], [dnl
81 Table: Reading 1 record from `data.txt'.
82 Variable,Record,Columns,Format
83 avar,1,1-  5,F5.0
84 bvar,1,6- 10,F5.0
85
86 Table: Data List
87 Case Number,avar,bvar
88 1,18,1
89 2,19,7
90 3,20,26
91 4,21,76
92 5,22,57
93 6,23,58
94 7,24,38
95 8,25,38
96 9,26,30
97 10,27,21
98 11,28,23
99 ])
100 AT_CLEANUP
101
102 # Checks for a crash when LIST did not include the variables from SPLIT
103 # FILE in the same positions (bug #30684).
104 AT_SETUP([LIST with split file])
105 AT_DATA([data.txt], [dnl
106 a 1
107 a 2
108 a 3
109 b 1
110 c 4
111 c 5
112 ])
113 AT_DATA([list.sps], [dnl
114 DATA LIST LIST NOTABLE FILE='data.txt'/s (a1) n.
115 SPLIT FILE BY s.
116 LIST n.
117 ])
118 AT_CHECK([pspp -o pspp.csv list.sps])
119 AT_CHECK([cat pspp.csv], [0], [dnl
120 Variable,Value,Label
121 s,a,
122
123 Table: Data List
124 n
125 1.00
126 2.00
127 3.00
128
129 Variable,Value,Label
130 s,b,
131
132 Table: Data List
133 n
134 1.00
135
136 Variable,Value,Label
137 s,c,
138
139 Table: Data List
140 n
141 4.00
142 5.00
143 ])
144 AT_CLEANUP
145
146 AT_SETUP([LIST lots of variables])
147 AT_DATA([data.txt], [dnl
148 767532466348513789073483106409
149 888693089424177542378334186760
150 492611507909187152726427852242
151 819848892023195875879332001491
152 452777898709563729845541516650
153 239961967077732760663525115073
154 ])
155 AT_DATA([list.sps], [dnl
156 DATA LIST FILE='data.txt' NOTABLE/x01 to x30 1-30.
157 LIST.
158 ])
159 AT_CHECK([pspp -o pspp.csv list.sps])
160 AT_CHECK([cat pspp.csv], [0], [dnl
161 Table: Data List
162 x01,x02,x03,x04,x05,x06,x07,x08,x09,x10,x11,x12,x13,x14,x15,x16,x17,x18,x19,x20,x21,x22,x23,x24,x25,x26,x27,x28,x29,x30
163 7,6,7,5,3,2,4,6,6,3,4,8,5,1,3,7,8,9,0,7,3,4,8,3,1,0,6,4,0,9
164 8,8,8,6,9,3,0,8,9,4,2,4,1,7,7,5,4,2,3,7,8,3,3,4,1,8,6,7,6,0
165 4,9,2,6,1,1,5,0,7,9,0,9,1,8,7,1,5,2,7,2,6,4,2,7,8,5,2,2,4,2
166 8,1,9,8,4,8,8,9,2,0,2,3,1,9,5,8,7,5,8,7,9,3,3,2,0,0,1,4,9,1
167 4,5,2,7,7,7,8,9,8,7,0,9,5,6,3,7,2,9,8,4,5,5,4,1,5,1,6,6,5,0
168 2,3,9,9,6,1,9,6,7,0,7,7,7,3,2,7,6,0,6,6,3,5,2,5,1,1,5,0,7,3
169 ])
170 AT_CLEANUP
171
172 AT_SETUP([LIST selected cases])
173 AT_DATA([data.txt], [dnl
174 7675324663
175 8886930894
176 4926115079
177 8198488920
178 4527778987
179 2399619670
180 1667799691
181 1623914684
182 3681393233
183 6418731145
184 2284534083
185 6617637452
186 9865713582
187 1163234537
188 9981663637
189 6821567746
190 0952774952
191 1641790193
192 3763182871
193 2046820753
194 7970620091
195 4841176017
196 6949973797
197 1396285996
198 0700489524
199 ])
200 AT_DATA([list.sps], [dnl
201 DATA LIST FILE='data.txt' NOTABLE/x0 to x9 1-10.
202 LIST /CASES=FROM 6 TO 20 BY 5.
203 LIST /CASES=4.
204 LIST /CASES=BY 10.
205 LIST /CASES=FROM 25.
206 LIST /CASES=FROM 26.
207 ])
208 AT_CHECK([pspp -o pspp.csv list.sps])
209 AT_CHECK([cat pspp.csv], [0], [dnl
210 Table: Data List
211 x0,x1,x2,x3,x4,x5,x6,x7,x8,x9
212 2,3,9,9,6,1,9,6,7,0
213 2,2,8,4,5,3,4,0,8,3
214 6,8,2,1,5,6,7,7,4,6
215
216 Table: Data List
217 x0,x1,x2,x3,x4,x5,x6,x7,x8,x9
218 7,6,7,5,3,2,4,6,6,3
219 8,8,8,6,9,3,0,8,9,4
220 4,9,2,6,1,1,5,0,7,9
221 8,1,9,8,4,8,8,9,2,0
222
223 Table: Data List
224 x0,x1,x2,x3,x4,x5,x6,x7,x8,x9
225 7,6,7,5,3,2,4,6,6,3
226 2,2,8,4,5,3,4,0,8,3
227 7,9,7,0,6,2,0,0,9,1
228
229 Table: Data List
230 x0,x1,x2,x3,x4,x5,x6,x7,x8,x9
231 0,7,0,0,4,8,9,5,2,4
232
233 Table: Data List
234 x0,x1,x2,x3,x4,x5,x6,x7,x8,x9
235 ])
236 AT_CLEANUP
237
238 dnl This program tests for a bug which caused a buffer overflow
239 dnl when the list command attempted to write very long strings.
240 AT_SETUP([LIST very long string])
241 AT_DATA([list.sps], [dnl
242 INPUT PROGRAM.
243 STRING foo (a2000).
244 + COMPUTE foo=CONCAT(RPAD('A',1999, 'x'), 'Z').
245 END CASE.
246 END FILE.
247 END INPUT PROGRAM.
248
249 EXECUTE.
250
251 DISPLAY VARIABLES.
252
253 LIST.
254 ])
255 AT_CHECK([pspp -o pspp.csv list.sps])
256 AT_CHECK([cat pspp.csv], [0], [dnl
257 Variable,Description,Position
258 foo,Format: A2000,1
259
260 Table: Data List
261 foo
262 Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxZ
263 ])
264 AT_CLEANUP
265
266
267
268 AT_SETUP([LIST crash on invalid input])
269
270 AT_DATA([list.sps], [dnl
271 DATA LIST LIST /`$b.
272 BEGIN DATA.
273 1 3
274 4 6
275 7 9
276 END DATA.
277
278 LIST.
279 ])
280
281 AT_CHECK([pspp -o pspp.csv list.sps], [1], [ignore])
282
283 AT_CLEANUP