e119f1033bc4a5794dc54c6f965a11d91ab59a86
[pspp-builds.git] / tests / language / utilities / insert.at
1 AT_BANNER([INSERT])
2
3 dnl Create a file "batch.sps" that is valid syntax only in batch mode.
4 m4_define([CREATE_BATCH_SPS], 
5   [AT_DATA([batch.sps], [dnl
6 input program.
7 +  loop #i = 1 to 5.
8 +    compute z = #i
9 +    end case.
10 +  end loop
11 end file.
12 end input program.
13 ])])
14
15 AT_SETUP([INSERT SYNTAX=INTERACTIVE])
16 CREATE_BATCH_SPS
17 AT_DATA([insert.sps], [dnl
18 INSERT 
19   FILE='batch.sps'
20   SYNTAX=INTERACTIVE.
21 LIST.
22 ])
23 AT_CHECK([pspp -o pspp.csv insert.sps], [1], [dnl
24 batch.sps:2: error: INPUT PROGRAM: Syntax error at `+': expecting command name.
25 batch.sps:3: error: INPUT PROGRAM: Syntax error at `+': expecting command name.
26 batch.sps:5: error: INPUT PROGRAM: Syntax error at `+': expecting command name.
27 batch.sps:7: error: Input program did not create any variables.
28 insert.sps:4: error: LIST: LIST is allowed only after the active file has been defined.
29 ])
30 AT_CLEANUP
31
32 AT_SETUP([INSERT SYNTAX=BATCH])
33 CREATE_BATCH_SPS
34 AT_DATA([insert.sps], [dnl
35 INSERT 
36   FILE='batch.sps'
37   SYNTAX=BATCH.
38 LIST.
39 ])
40 AT_CHECK([pspp -o pspp.csv insert.sps])
41 AT_CHECK([cat pspp.csv], [0], [dnl
42 Table: Data List
43 z
44 1.00
45 2.00
46 3.00
47 4.00
48 5.00
49 ])
50 AT_CLEANUP
51
52 AT_SETUP([INSERT CD=NO])
53 AT_DATA([insert.sps], [INSERT FILE='Dir1/foo.sps'.
54 LIST.
55 ])
56 mkdir Dir1
57 AT_DATA([Dir1/foo.sps], [INSERT FILE='bar.sps' CD=NO.
58 ])
59 AT_DATA([Dir1/bar.sps],
60   [DATA LIST LIST /x *.
61 BEGIN DATA.
62 1
63 2
64 3
65 END DATA.
66 ])
67 AT_CHECK([pspp -o pspp.csv insert.sps], [1], [dnl
68 Dir1/foo.sps:1: error: INSERT: Can't find `bar.sps' in include file search path.
69 insert.sps:2: error: LIST: LIST is allowed only after the active file has been defined.
70 ])
71 AT_CLEANUP
72
73 AT_SETUP([INSERT CD=YES])
74 AT_DATA([insert.sps], [INSERT FILE='Dir1/foo.sps' CD=YES.
75 LIST.
76 ])
77 mkdir Dir1
78 AT_DATA([Dir1/foo.sps], [INSERT FILE='bar.sps'.
79 ])
80 AT_DATA([Dir1/bar.sps],
81   [DATA LIST LIST /x *.
82 BEGIN DATA.
83 1
84 2
85 3
86 END DATA.
87 ])
88 AT_CHECK([pspp -o pspp.csv insert.sps])
89 AT_CHECK([cat pspp.csv], [0], [dnl
90 Table: Reading free-form data from INLINE.
91 Variable,Format
92 x,F8.0
93
94 Table: Data List
95 x
96 1.00
97 2.00
98 3.00
99 ])
100 AT_CLEANUP
101
102 m4_define([CREATE_ERROR_SPS],
103   [AT_DATA([error.sps], [dnl
104 DATA LIST NOTABLE LIST /x *.
105 BEGIN DATA.
106 1
107 2
108 3
109 END DATA.
110
111 * The following line is erroneous
112
113 DISPLAY AKSDJ.
114 ])])
115
116 AT_SETUP([INSERT ERROR=STOP])
117 CREATE_ERROR_SPS
118 AT_DATA([insert.sps], [INSERT FILE='error.sps' ERROR=STOP.
119 LIST.
120 ])
121 AT_CHECK([pspp -o pspp.csv insert.sps], [1], [dnl
122 error.sps:10: error: DISPLAY: AKSDJ is not a variable name.
123 warning: Error encountered while ERROR=STOP is effective.
124 error.sps:10: error: Stopping syntax file processing here to avoid a cascade of dependent command failures.
125 ])
126 AT_CLEANUP
127
128 AT_SETUP([INSERT ERROR=CONTINUE])
129 CREATE_ERROR_SPS
130 AT_DATA([insert.sps], [INSERT FILE='error.sps' ERROR=CONTINUE.
131 LIST.
132 ])
133 AT_CHECK([pspp -o pspp.csv insert.sps], [1], [dnl
134 error.sps:10: error: DISPLAY: AKSDJ is not a variable name.
135 ])
136 AT_CHECK([cat pspp.csv], [0], [dnl
137 error.sps:10: error: DISPLAY: AKSDJ is not a variable name.
138
139 Table: Data List
140 x
141 1.00
142 2.00
143 3.00
144 ])
145 AT_CLEANUP
146
147 dnl Test for regression against bug #24569 in which PSPP crashed
148 dnl upon attempt to insert a nonexistent file.
149 AT_SETUP([INSERT nonexistent file])
150 AT_DATA([insert.sps], [dnl
151 INSERT 
152   FILE='nonexistent'
153   ERROR=CONTINUE.
154   .
155
156 LIST.
157 ])
158 AT_CHECK([pspp -O format=csv insert.sps], [1], [dnl
159 insert.sps:3: error: INSERT: Can't find `nonexistent' in include file search path.
160
161 insert.sps:6: error: LIST: LIST is allowed only after the active file has been defined.
162 ])
163 AT_CLEANUP