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