eval_parser evaluates the following programm fully (until --STOP) but returns MALA_ST...
[mala.git] / tests / 30stdmodule.tests
bloba7b0171cea46f07ebe93d352235715ddf9032957
1 # arch-tag: org.pipapo.mala.tests.stdmodule
3 TESTING "stdmodule tests:" ./test-mala
6 TEST "cat three 1st way" --CAT --CAT foo bar baz <<END
7 stdout: .
8 literal: foobarbaz.
9 variable: (null)
10 state: LITERAL
11 END
14 TEST "cat three 2nd way" --CAT foo --CAT bar baz <<END
15 stdout: .
16 literal: foobarbaz.
17 variable: (null)
18 state: LITERAL
19 END
22 TEST "cat missing arg 1st way" --CAT --CAT foo bar <<END
23 stdout: .
24 literal: --ERROR.
25 literal: --CAT.
26 literal: foobar.
27 literal: --ERROR-MISSING-ARGUMENT.
28 variable: (null)
29 state: ENOACTION
30 END
33 TEST "cat missing arg 2nd way" --CAT foo --CAT bar <<END
34 stdout: .
35 literal: --ERROR.
36 literal: --CAT.
37 literal: foo.
38 literal: --ERROR.
39 literal: --CAT.
40 literal: bar.
41 literal: --ERROR-MISSING-ARGUMENT.
42 variable: (null)
43 state: ENOACTION
44 END
47 TEST "missing arg at --PRINT" --PRINT <<END
48 stdout: .
49 literal: --ERROR.
50 literal: --PRINT.
51 literal: --ERROR-MISSING-ARGUMENT.
52 variable: (null)
53 state: ENOACTION
54 END
57 TEST "--PRINT --LITERAL" --PRINT --LITERAL --LITERAL <<END
58 stdout: --LITERAL.
59 variable: (null)
60 state: STATEMENT
61 END
64 TEST "--PRINT and --NL" --PRINT "foo bar" --NL <<END
65 stdout: foo bar
67 variable: (null)
68 state: STATEMENT
69 END
72 TEST "begin w/o end" --BEGIN <<END
73 stdout: .
74 literal: --ERROR-MISSING-END.
75 literal: --BEGIN.
76 variable: (null)
77 state: ENOACTION
78 END
81 TEST "begin empty end" --BEGIN --END <<END
82 stdout: .
83 variable: (null)
84 state: STATEMENT
85 END
88 TEST "begin single word" --BEGIN foo --END <<END
89 stdout: .
90 literal: foo.
91 variable: (null)
92 state: LITERAL
93 END
96 TEST "begin 2 words" --BEGIN foo bar --END <<END
97 stdout: .
98 literal: foo.
99 literal: bar.
100 variable: (null)
101 state: LITERAL
105 TEST "begin single macro" --BEGIN '%2%1' --END foo bar <<END
106 stdout: .
107 literal: barfoo.
108 variable: (null)
109 state: LITERAL
113 TEST "begin double macro" --BEGIN '%2' '%1' --END foo bar <<END
114 stdout: .
115 literal: bar.
116 literal: foo.
117 variable: (null)
118 state: LITERAL
122 TEST "missing name at --DEF" --DEF <<END
123 stdout: .
124 literal: --ERROR.
125 literal: --DEF.
126 literal: --ERROR-MISSING-ARGUMENT.
127 variable: (null)
128 state: ENOACTION
132 TEST "missing body at --DEF" --DEF foo <<END
133 stdout: .
134 literal: --ERROR.
135 literal: --DEF.
136 literal: foo.
137 literal: --ERROR-MISSING-ARGUMENT.
138 variable: (null)
139 state: ENOACTION
143 TEST "define macro w/o parameter" --DEF foo --BEGIN bar baz --END <<END
144 stdout: .
145 variable: (null)
146 state: STATEMENT
150 TEST "substitute"  --DEF foo bar foo <<END
151 stdout: .
152 literal: bar.
153 variable: (null)
154 state: LITERAL
158 TEST "expand macro w/o parameter" --DEF foo --BEGIN bar baz --END foo <<END
159 stdout: .
160 literal: bar.
161 literal: baz.
162 variable: (null)
163 state: LITERAL
167 TEST "expand macro w/ parameter" --DEF foo --BEGIN %1 bar --END foo baz <<END
168 stdout: .
169 literal: baz.
170 literal: bar.
171 variable: (null)
172 state: LITERAL
176 TEST "%% expand test" --DEF foo foo%%bar foo baz <<END
177 stdout: .
178 literal: foo%bar.
179 literal: baz.
180 variable: (null)
181 state: LITERAL
185 TEST "%0 expand test" --DEF foo foo%0bar foo baz <<END
186 stdout: .
187 literal: foofoobar.
188 literal: baz.
189 variable: (null)
190 state: LITERAL
194 PLANNED "%-0 expand test" --DEF foo bar barf --END-DEF --DEF foo -BEEGIN baz %-0 --END foo gnarf <<END
195 arg: baz
196 arg: bar
197 arg: barf
198 arg: gnarf
199 variable: (null)
200 state: CONTINUE
204 TEST "define nested macro w/o parameter" --DEF foo --BEGIN bar --DEF baz --BEGIN barf gnarf --END --END baz foo baz <<END
205 stdout: .
206 literal: baz.
207 literal: bar.
208 literal: barf.
209 literal: gnarf.
210 variable: (null)
211 state: LITERAL
215 PLANNED "variable expansion in macro" variable = bar --DEF foo '$variable' --END-DEF --PRINT foo --NL <<END
216 stdout: bar
217 variable: (null)
218 state: CONTINUE
222 TEST "missing macro argument" --DEF foo %2 foo bar <<END
223 stdout: .
224 literal: --ERROR.
225 literal: foo.
226 literal: bar.
227 literal: --ERROR-MISSING-ARGUMENT.
228 variable: (null)
229 state: ENOACTION
233 TEST "stale --END" --PRINT foo --END <<END
234 stdout: foo.
235 literal: --ERROR-END-WITHOUT-BEGIN.
236 literal: --END.
237 variable: (null)
238 state: ENOACTION
242 TEST "escaped argument" --DEF foo %%1 foo <<END
243 stdout: .
244 literal: %1.
245 variable: (null)
246 state: LITERAL
250 TEST "invalid macro" --DEF foo %illegal foo bar <<END
251 stdout: .
252 literal: --ERROR-MACRO-SYNTAX.
253 literal: --DEF.
254 literal: foo.
255 literal: %illegal.
256 literal: foo.
257 literal: bar.
258 variable: (null)
259 state: ENOACTION
263 PLANNED "definition redefinition" --DEF --substitute --ESCAPE --DEF %1 %2 --ESCAPE --END-DEF --END-DEF --substitute foo bar foo <<END
264 stdout: 
265 arg: bar
266 variable: (null)
267 state: CONTINUE
271 PLANNED "--no-PRINT" --no-PRINT <<END
272 stdout: 
273 prg: --ERROR-UNEXPECTED-NEGATED
274 prg: --PRINT
275 prg: --BEFORE-HERE
276 variable: (null)
277 state: ENOACTION
280 PLANNED "negated --DEF" ! --DEF foo bar --END-DEF <<END
281 stdout: 
282 prg: --ERROR-NEGATED
283 prg: --DEF
284 prg: --HERE-ERROR-NEGATED
285 prg: foo
286 prg: bar
287 prg: --END-DEF
288 variable: (null)
289 state: ENOACTION
293 TEST "printl" --PRINTL --LITERAL foo <<END
294 stdout: foo
296 variable: (null)
297 state: STATEMENT
301 TEST "undef substitution" --DEF foo bar foo --DEL --LITERAL foo foo <<END
302 stdout: .
303 literal: bar.
304 literal: foo.
305 variable: (null)
306 state: LITERAL
310 TEST "delete error" --DEL foo <<END
311 stdout: .
312 literal: --ERROR-ACTION-NOT-DEFINED.
313 literal: --DEL.
314 literal: foo.
315 variable: (null)
316 state: ENOACTION
320 TEST "remove literal" --REMOVE foo <<END
321 stdout: .
322 variable: (null)
323 state: STATEMENT
327 TEST "remove printl" --REMOVE --PRINTL foo <<END
328 stdout: .
329 variable: (null)
330 state: STATEMENT
334 TEST "remove def" --REMOVE --DEF foo bar baz <<END
335 stdout: .
336 literal: baz.
337 variable: (null)
338 state: LITERAL
342 PLANNED TEST "simple not true" --NOT --TRUE <<END
343 stdout: .
344 literal: --FALSE.
345 variable: (null)
346 state: LITERAL
350 PLANNED TEST "simple not false" --NOT --FALSE <<END
351 stdout: .
352 literal: --TRUE.
353 variable: (null)
354 state: LITERAL
358 PLANNED TEST "double not true" --NOT --NOT --TRUE <<END
359 stdout: 
360 literal: --TRUE
361 variable: (null)
362 state: LITERAL
366 PLANNED TEST "double not false" --NOT --NOT --FALSE <<END
367 stdout: 
368 literal: --FALSE
369 variable: (null)
370 state: LITERAL
374 TEST "delete expand" --DEF foo --BEGIN bar baz --END foo --DEL --LITERAL foo foo <<END
375 stdout: .
376 literal: bar.
377 literal: baz.
378 literal: foo.
379 variable: (null)
380 state: LITERAL
384 TEST "delete macro" --DEF foo --BEGIN bar %1 --END foo baz --DEL --LITERAL foo foo baz <<END
385 stdout: .
386 literal: bar.
387 literal: baz.
388 literal: foo.
389 literal: baz.
390 variable: (null)
391 state: LITERAL
395 PLANNED "redef macro" --DEF foo bar --REDEF foo baz foo goo --DEL foo --DEL foo <<END
396 stdout: literal: baz
397 literal: goo
398 prg: --ERROR-UNKNOWN-ACTION
399 prg: --DEL
400 prg: foo
401 prg: --HERE-ERROR-UNKNOWN-ACTION
402 variable: (null)
403 state: ENOACTION
406 PLANNED "defined" --DEFINED --DEF ! --DEFINED foo --DEFINED bar --NO-DEFINED --DEFINED <<END
407 stdout: 
408 literal: --TRUE
409 literal: --TRUE
410 literal: --FALSE
411 literal: --FALSE
412 variable: (null)
413 state: 1
416 PLANNED "attach" --DEF foo bar --END-DEF --DEF baz barf --END-DEF --ATTACH foo baz foo --DEL baz foo <<END
417 stdout: 
418 literal: bar
419 literal: foo
420 variable: (null)
421 state: CONTINUE
424 PLANNED "detach" --DEF foo bar --END-DEF --DEF baz barf --END-DEF --ATTACH foo baz foo --DETACH foo --DEL baz foo <<END
425 stdout: 
426 literal: bar
427 literal: bar
428 variable: (null)
429 state: CONTINUE
433 TEST "ifelse true" --IF-ELSE --TRUE success fail bar <<END
434 stdout: .
435 literal: success.
436 literal: bar.
437 variable: (null)
438 state: LITERAL
442 TEST "ifelse false" --IF-ELSE --FALSE success fail bar <<END
443 stdout: .
444 literal: fail.
445 literal: bar.
446 variable: (null)
447 state: LITERAL
451 TEST "if else blocks, true" --IF-ELSE --TRUE --BEGIN --PRINTL true --END --BEGIN --PRINTL false --END <<END
452 stdout: true
454 variable: (null)
455 state: STATEMENT
459 TEST "if else blocks, false" --IF-ELSE --FALSE --BEGIN --PRINTL true --END --BEGIN --PRINTL false --END <<END
460 stdout: false
462 variable: (null)
463 state: STATEMENT
467 TEST "eval" --PRINT --EVAL --DEF foo evaluated --STOP finally foo <<END
468 stdout: finally.
469 literal: evaluated.
470 variable: (null)
471 state: LITERAL
475 TEST "Simple printwraped" --DEF COL 40 --PRINTWRAPED COL 10 2 8 $'foo\t- bar\t  right' --PRINTL 12345678901234567890123456789012345678901234567890 <<END
476 stdout:   foo     - bar                    right
477 12345678901234567890123456789012345678901234567890
479 variable: (null)
480 state: STATEMENT
483 TEST "printwraped with wrap" --DEF COL 40 --PRINTWRAPED COL 10 2 8 $'foo\t- bar\t  right\nfoo\t- bar baz foobar barf bazbarf gnat\t right' --PRINTL 12345678901234567890123456789012345678901234567890 <<END
484 stdout:   foo     - bar                    right
485   foo     - bar baz foobar barf bazbarf
486             gnat                   right
487 12345678901234567890123456789012345678901234567890
489 variable: (null)
490 state: STATEMENT
494 PLANNED "negated --LITERAL" ! --LITERAL <<END
495 variable: (null)