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