lexer: Reimplement for better testability and internationalization.
[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.1-2.4: error: INPUT PROGRAM: Syntax error at `loop': expecting end of command.
25 batch.sps:3: error: COMPUTE: COMPUTE is allowed only after the active file has been defined or inside INPUT PROGRAM.
26 batch.sps:4: error: END CASE: END CASE is allowed only inside INPUT PROGRAM.
27 insert.sps:4: error: LIST: LIST is allowed only after the active file has been defined.
28 ])
29 AT_CLEANUP
30
31 AT_SETUP([INSERT SYNTAX=BATCH])
32 CREATE_BATCH_SPS
33 AT_DATA([insert.sps], [dnl
34 INSERT 
35   FILE='batch.sps'
36   SYNTAX=BATCH.
37 LIST.
38 ])
39 AT_CHECK([pspp -o pspp.csv insert.sps])
40 AT_CHECK([cat pspp.csv], [0], [dnl
41 Table: Data List
42 z
43 1.00
44 2.00
45 3.00
46 4.00
47 5.00
48 ])
49 AT_CLEANUP
50
51 AT_SETUP([INSERT CD=NO])
52 AT_DATA([insert.sps], [INSERT FILE='Dir1/foo.sps'.
53 LIST.
54 ])
55 mkdir Dir1
56 AT_DATA([Dir1/foo.sps], [INSERT FILE='bar.sps' CD=NO.
57 ])
58 AT_DATA([Dir1/bar.sps],
59   [DATA LIST LIST /x *.
60 BEGIN DATA.
61 1
62 2
63 3
64 END DATA.
65 ])
66 AT_CHECK([pspp -o pspp.csv insert.sps], [1], [dnl
67 Dir1/foo.sps:1: error: INSERT: Can't find `bar.sps' in include file search path.
68 insert.sps:2: error: LIST: LIST is allowed only after the active file has been defined.
69 ])
70 AT_CLEANUP
71
72 AT_SETUP([INSERT CD=YES])
73 AT_DATA([insert.sps], [INSERT FILE='Dir1/foo.sps' CD=YES.
74 LIST.
75 ])
76 mkdir Dir1
77 AT_DATA([Dir1/foo.sps], [INSERT FILE='bar.sps'.
78 ])
79 AT_DATA([Dir1/bar.sps],
80   [DATA LIST LIST /x *.
81 BEGIN DATA.
82 1
83 2
84 3
85 END DATA.
86 ])
87 AT_CHECK([pspp -o pspp.csv insert.sps])
88 AT_CHECK([cat pspp.csv], [0], [dnl
89 Table: Reading free-form data from INLINE.
90 Variable,Format
91 x,F8.0
92
93 Table: Data List
94 x
95 1.00
96 2.00
97 3.00
98 ])
99 AT_CLEANUP
100
101 m4_define([CREATE_ERROR_SPS],
102   [AT_DATA([error.sps], [dnl
103 DATA LIST NOTABLE LIST /x *.
104 BEGIN DATA.
105 1
106 2
107 3
108 END DATA.
109
110 * The following line is erroneous
111
112 DISPLAY AKSDJ.
113 LIST.
114 ])])
115
116 AT_SETUP([INSERT ERROR=STOP])
117 CREATE_ERROR_SPS
118 AT_DATA([insert.sps], [INSERT FILE='error.sps' ERROR=STOP.
119 ])
120 AT_CHECK([pspp -o pspp.csv insert.sps], [1], [dnl
121 error.sps:10: error: DISPLAY: AKSDJ is not a variable name.
122 warning: Error encountered while ERROR=STOP is effective.
123 ])
124 AT_CLEANUP
125
126 AT_SETUP([INSERT ERROR=CONTINUE])
127 CREATE_ERROR_SPS
128 AT_DATA([insert.sps], [INSERT FILE='error.sps' ERROR=CONTINUE.
129 ])
130 AT_CHECK([pspp -o pspp.csv insert.sps], [1], [dnl
131 error.sps:10: error: DISPLAY: AKSDJ is not a variable name.
132 ])
133 AT_CHECK([cat pspp.csv], [0], [dnl
134 error.sps:10: error: DISPLAY: AKSDJ is not a variable name.
135
136 Table: Data List
137 x
138 1.00
139 2.00
140 3.00
141 ])
142 AT_CLEANUP
143
144 dnl Test for regression against bug #24569 in which PSPP crashed
145 dnl upon attempt to insert a nonexistent file.
146 AT_SETUP([INSERT nonexistent file])
147 AT_DATA([insert.sps], [dnl
148 INSERT 
149   FILE='nonexistent'
150   ERROR=CONTINUE.
151   .
152
153 LIST.
154 ])
155 AT_CHECK([pspp -O format=csv insert.sps], [1], [dnl
156 insert.sps:2: error: INSERT: Can't find `nonexistent' in include file search path.
157
158 insert.sps:6: error: LIST: LIST is allowed only after the active file has been defined.
159 ])
160 AT_CLEANUP