Add copyright and licence notices to files which lack them.
[pspp] / tests / language / control / do-if.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([DO IF])
17
18 AT_SETUP([DO IF])
19 (for a in 0 1 ' '; do
20     for b in 0 1 ' '; do
21         for c in 0 1 ' '; do
22             for d in 0 1 ' '; do
23                 abcd=$a$b$c$d
24                 echo "$abcd" 1>&3
25                 if test "$a" = "1"; then
26                     echo " $abcd A"
27                 elif test "$a" = " "; then
28                     :
29                 elif test "$b" = "1"; then
30                     echo " $abcd B"
31                 elif test "$b" = " "; then
32                     :
33                 elif test "$c" = "1"; then
34                     echo " $abcd C"
35                 elif test "$c" = " "; then
36                     :
37                 elif test "$d" = "1"; then
38                     echo " $abcd D"
39                 elif test "$d" = " "; then
40                     :
41                 else
42                     echo " $abcd E"
43                 fi
44             done
45         done
46     done
47 done) >expout 3>do-if.txt || exit 99
48 AT_DATA([do-if.sps], [dnl
49 DATA LIST FILE="do-if.txt"/A B C D 1-4 ABCD 1-4 (A).
50 DO IF A.
51 PRINT OUTFILE="do-if.out"/ABCD 'A'.
52 ELSE IF B.
53 PRINT OUTFILE="do-if.out"/ABCD 'B'.
54 ELSE IF C.
55 PRINT OUTFILE="do-if.out"/ABCD 'C'.
56 ELSE IF D.
57 PRINT OUTFILE="do-if.out"/ABCD 'D'.
58 ELSE.
59 PRINT OUTFILE="do-if.out"/ABCD 'E'.
60 END IF.
61 EXECUTE.
62 ])
63 AT_CHECK([pspp do-if.sps], [0], [ignore])
64 AT_CHECK([cat do-if.out], [0], [expout])
65 AT_CLEANUP
66
67 AT_SETUP([unpaired END IF crash])
68 AT_DATA([do-if.sps], [dnl
69 DATA LIST LIST NOTABLE/a b c.
70 END IF.
71 ])
72 AT_CHECK([pspp -O format=csv do-if.sps], [1], [dnl
73 do-if.sps:2: error: END IF: This command cannot appear outside DO IF...END IF.
74 ])
75 AT_CLEANUP
76
77
78
79 AT_SETUP([ELSE without DO IF])
80 AT_DATA([do-if.sps], [dnl
81 DATA lIST NOTABLE LIST /QUA BRA *.
82 BEGIN DATA
83 4  1
84 6  3
85 END DATA
86
87 ELSE QUA 'A string'.
88
89 EXECUTE.
90 ])
91 AT_CHECK([pspp -O format=csv do-if.sps], [1], [dnl
92 do-if.sps:7: error: ELSE: This command cannot appear outside DO IF...END IF.
93
94 do-if.sps:9: error: Stopping syntax file processing here to avoid a cascade of dependent command failures.
95 ])
96 AT_CLEANUP
97