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