command: Fix delayed execution of FINISH.
[pspp] / tests / language / command.at
1 AT_BANNER([command parser])
2
3 dnl Tests for a bug which crashed pspp when given certain invalid input.
4 AT_SETUP([command parser crash bug])
5 AT_DATA([command.sps], [dnl
6 DATA rubbish.
7 EXECUTE.
8 ])
9 AT_CHECK([pspp -O format=csv command.sps], [1], [dnl
10 command.sps:1: error: Unknown command `DATA rubbish'.
11
12 command.sps:2: error: EXECUTE: EXECUTE is allowed only after the active dataset has been defined.
13 ])
14 AT_CLEANUP
15
16 dnl Tests for a bug where FINISH or EXIT wasn't executed until the lexer
17 dnl read the first token of the next command.
18 dnl
19 dnl (If this reecurs, the the test will run forever.)
20 AT_SETUP([FINISH executes immediately])
21 AT_CHECK([(echo "FINISH."; while :; do echo; done) | pspp])
22 AT_CLEANUP
23
24 AT_BANNER([ERASE])
25
26 AT_SETUP([ERASE -- safer mode])
27 AT_DATA([foobar], [contents
28 ])
29 AT_DATA([erase.sps], [dnl
30 set safer on
31
32 erase FILE='foobar'.
33 ])
34 AT_CHECK([pspp -O format=csv erase.sps], [1], [dnl
35 erase.sps:3: error: ERASE: This command not allowed when the SAFER option is set.
36 ])
37 AT_CHECK([cat foobar], [0], [contents
38 ])
39 AT_CLEANUP
40
41 AT_SETUP([ERASE -- not safer mode])
42 AT_DATA([foobar], [contents
43 ])
44 AT_CHECK([test -e foobar])
45 AT_DATA([erase.sps], [dnl
46 erase FILE='foobar'.
47 ])
48 AT_CHECK([pspp -O format=csv erase.sps])
49 AT_CHECK([test ! -e foobar])
50 AT_CLEANUP
51
52 AT_BANNER([N OF CASES])
53
54 AT_SETUP([N OF CASES])
55 AT_DATA([n-of-cases.sps], [dnl
56 INPUT PROGRAM.
57 LOOP #i = 1 TO 100.
58 COMPUTE x=#i.
59 END CASE.
60 END LOOP.
61 END FILE.
62 END INPUT PROGRAM.
63
64 N OF CASES 15.
65
66 LIST.
67 ])
68 AT_CHECK([pspp -O format=csv n-of-cases.sps], [0], [dnl
69 Table: Data List
70 x
71 1.00
72 2.00
73 3.00
74 4.00
75 5.00
76 6.00
77 7.00
78 8.00
79 9.00
80 10.00
81 11.00
82 12.00
83 13.00
84 14.00
85 15.00
86 ])
87 AT_CLEANUP
88
89 AT_BANNER([COMMENT])
90
91 dnl Tests for a bug wherein a comment just before end-of-file caused an
92 dnl infinite loop.
93 AT_SETUP([COMMENT at end of file])
94 AT_DATA([comment.sps], [dnl
95 COMMENT this is a comment at end of file.
96 ])
97 AT_CHECK([pspp -O format=csv comment.sps])
98 AT_CLEANUP