f676e308bb5b72b91040201d6395675513b015c9
[pspp] / tests / language / data-io / inpt-pgm.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([INPUT PROGRAM])
18
19 dnl Tests for a bug which caused a crash when
20 dnl reading invalid INPUT PROGRAM syntax.
21 AT_SETUP([INPUT PROGRAM invalid syntax crash])
22 AT_DATA([input-program.sps], [dnl
23 INPUT PROGRAM.
24 DATA LIST NOTABLE /a 1-9.
25 BEGIN DATA
26 123456789
27 END DATA.
28 END INPUT PROGRAM.
29 ])
30 AT_CHECK([pspp -O format=csv input-program.sps], [1], [dnl
31 input-program.sps:3: error: BEGIN DATA: BEGIN DATA is not allowed inside INPUT PROGRAM.
32 ])
33 AT_CLEANUP
34
35 dnl Tests for bug #21108, a crash when
36 dnl reading invalid INPUT PROGRAM syntax.
37 AT_SETUP([INPUT PROGRAM invalid syntax crash])
38 AT_DATA([input-program.sps], [dnl
39 INPUT PROGRAM.
40 DATA LIST LIST NOTABLE /x.
41 END FILE.
42 END INPUT PROGRAM.
43
44 DESCRIPTIVES x.
45 ])
46 AT_CHECK([pspp -O format=csv input-program.sps], [1], [dnl
47 error: DESCRIPTIVES: Syntax error at end of input: expecting BEGIN.
48 ])
49 AT_CLEANUP
50
51 dnl Tests for bug #38782, an infinite loop processing an empty input program.
52 AT_SETUP([INPUT PROGRAM infinite loop])
53 AT_DATA([input-program.sps], [dnl
54 INPUT PROGRAM.
55 STRING firstname lastname (a24) / address (a80).
56 END INPUT PROGRAM.
57 EXECUTE.
58 ])
59 AT_CHECK([pspp -O format=csv input-program.sps], [1], [dnl
60 input-program.sps:3: error: INPUT PROGRAM: Input program must contain DATA LIST or END FILE.
61
62 input-program.sps:4: error: EXECUTE: EXECUTE is allowed only after the active dataset has been defined.
63 ])
64 AT_CLEANUP
65
66 dnl Tests for bug #39097, a bug when an INPUT PROGRAM used VECTOR, was
67 dnl followed immediately by a call to proc_execute() (here via DATASET
68 dnl COPY), and then the input was actually used.
69 AT_SETUP([INPUT PROGRAM with VECTOR and EXECUTE])
70 AT_DATA([input-program.sps], [dnl
71 INPUT PROGRAM.
72 VECTOR vec(5).
73 LOOP #c = 1 to 10.
74  LOOP #v = 1 to 5.
75   COMPUTE vec(#v) = #v.
76  END LOOP.
77  END CASE.
78 END LOOP.
79 END FILE.
80 END INPUT PROGRAM.
81 DATASET COPY x.
82 LIST.
83 ])
84 AT_CHECK([pspp -O format=csv input-program.sps], [0], [dnl
85 Table: Data List
86 vec1,vec2,vec3,vec4,vec5
87 1.00,2.00,3.00,4.00,5.00
88 1.00,2.00,3.00,4.00,5.00
89 1.00,2.00,3.00,4.00,5.00
90 1.00,2.00,3.00,4.00,5.00
91 1.00,2.00,3.00,4.00,5.00
92 1.00,2.00,3.00,4.00,5.00
93 1.00,2.00,3.00,4.00,5.00
94 1.00,2.00,3.00,4.00,5.00
95 1.00,2.00,3.00,4.00,5.00
96 1.00,2.00,3.00,4.00,5.00
97 ])
98 AT_CLEANUP