AT_BANNER([DO IF])

AT_SETUP([DO IF])
(for a in 0 1 ' '; do
    for b in 0 1 ' '; do
	for c in 0 1 ' '; do
	    for d in 0 1 ' '; do
		abcd=$a$b$c$d
		echo "$abcd" 1>&3
		if test "$a" = "1"; then
		    echo " $abcd A"
		elif test "$a" = " "; then
		    :
		elif test "$b" = "1"; then
		    echo " $abcd B"
		elif test "$b" = " "; then
		    :
		elif test "$c" = "1"; then
		    echo " $abcd C"
		elif test "$c" = " "; then
		    :
		elif test "$d" = "1"; then
		    echo " $abcd D"
		elif test "$d" = " "; then
		    :
		else
		    echo " $abcd E"
		fi
	    done
	done
    done
done) >expout 3>do-if.txt || exit 99
AT_DATA([do-if.sps], [dnl
DATA LIST FILE="do-if.txt"/A B C D 1-4 ABCD 1-4 (A).
DO IF A.
PRINT OUTFILE="do-if.out"/ABCD 'A'.
ELSE IF B.
PRINT OUTFILE="do-if.out"/ABCD 'B'.
ELSE IF C.
PRINT OUTFILE="do-if.out"/ABCD 'C'.
ELSE IF D.
PRINT OUTFILE="do-if.out"/ABCD 'D'.
ELSE.
PRINT OUTFILE="do-if.out"/ABCD 'E'.
END IF.
EXECUTE.
])
AT_CHECK([pspp do-if.sps], [0], [ignore])
AT_CHECK([cat do-if.out], [0], [expout])
AT_CLEANUP

AT_SETUP([unpaired END IF crash])
AT_DATA([do-if.sps], [dnl
DATA LIST LIST NOTABLE/a b c.
END IF.
])
AT_CHECK([pspp -O format=csv do-if.sps], [1], [dnl
do-if.sps:2: error: END IF: This command cannot appear outside DO IF...END IF.
])
AT_CLEANUP
