+
+AT_SETUP([unary operator type mismatch])
+AT_KEYWORDS([expression expressions parse negative])
+AT_DATA([parse.sps], [dnl
+DEBUG EVALUATE /-'a'.
+DEBUG EVALUATE /----'a'.
+DEBUG EVALUATE /NOT 'a'.
+DEBUG EVALUATE /NOT NOT NOT 'a'.
+DEBUG EVALUATE /NOT F5.2.
+])
+AT_CHECK([pspp --testing-mode parse.sps], [1], [dnl
+parse.sps:1.17-1.20: error: DEBUG EVALUATE: The unary - operator requires a
+numeric operand.
+ 1 | DEBUG EVALUATE /-'a'.
+ | ^~~~
+
+parse.sps:1.18-1.20: note: DEBUG EVALUATE: The operand of - has type 'string'.
+ 1 | DEBUG EVALUATE /-'a'.
+ | ^~~
+
+-'a' => error
+
+parse.sps:2.17-2.23: error: DEBUG EVALUATE: The unary - operator requires a
+numeric operand.
+ 2 | DEBUG EVALUATE /----'a'.
+ | ^~~~~~~
+
+parse.sps:2.21-2.23: note: DEBUG EVALUATE: The operand of - has type 'string'.
+ 2 | DEBUG EVALUATE /----'a'.
+ | ^~~
+
+----'a' => error
+
+parse.sps:3.17-3.23: error: DEBUG EVALUATE: The unary NOT operator requires a
+numeric operand.
+ 3 | DEBUG EVALUATE /NOT 'a'.
+ | ^~~~~~~
+
+parse.sps:3.21-3.23: note: DEBUG EVALUATE: The operand of NOT has type
+'string'.
+ 3 | DEBUG EVALUATE /NOT 'a'.
+ | ^~~
+
+NOT 'a' => error
+
+parse.sps:4.17-4.31: error: DEBUG EVALUATE: The unary NOT operator requires a
+numeric operand.
+ 4 | DEBUG EVALUATE /NOT NOT NOT 'a'.
+ | ^~~~~~~~~~~~~~~
+
+parse.sps:4.29-4.31: note: DEBUG EVALUATE: The operand of NOT has type
+'string'.
+ 4 | DEBUG EVALUATE /NOT NOT NOT 'a'.
+ | ^~~
+
+NOT NOT NOT 'a' => error
+
+parse.sps:5.17-5.24: error: DEBUG EVALUATE: The unary NOT operator requires a
+numeric operand.
+ 5 | DEBUG EVALUATE /NOT F5.2.
+ | ^~~~~~~~
+
+parse.sps:5.21-5.24: note: DEBUG EVALUATE: The operand of NOT has type
+'format'.
+ 5 | DEBUG EVALUATE /NOT F5.2.
+ | ^~~~
+
+NOT F5.2 => error
+])
+AT_CLEANUP
+
+AT_SETUP([parsing with negative numbers])
+AT_KEYWORDS([expression expressions parse])
+AT_DATA([parse.sps], [dnl
+DEBUG EVALUATE NOOPT POSTFIX /-2**3.
+DEBUG EVALUATE NOOPT POSTFIX /-2**-3**-4.
+DEBUG EVALUATE/1 - 2.
+])
+AT_CHECK([pspp --testing-mode parse.sps], [0], [dnl
+number: n<2> number: n<3> POW NEG return_number
+
+parse.sps:2.31-2.40: warning: DEBUG EVALUATE: The exponentiation operator
+(`**') is left-associative: `a**b**c' equals `(a**b)**c', not `a**(b**c)'. To
+disable this warning, insert parentheses.
+ 2 | DEBUG EVALUATE NOOPT POSTFIX /-2**-3**-4.
+ | ^~~~~~~~~~
+
+number: n<2> number: n<-3> POW number: n<-4> POW NEG return_number
+
+1 - 2 => -1.00
+])
+AT_CLEANUP
+
+AT_SETUP([system variables])
+AT_KEYWORDS([expression expressions parse])
+AT_DATA([parse.sps], [dnl
+DEBUG EVALUATE /$WIDTH.
+DEBUG EVALUATE /$LENGTH.
+DEBUG EVALUATE /$SYSMIS.
+])
+AT_CHECK([pspp --testing-mode parse.sps], [0], [dnl
+$WIDTH => 79.00
+
+$LENGTH => 24.00
+
+$SYSMIS => sysmis
+])
+AT_CLEANUP
+
+# This test will fail if the current date changes during the test.
+AT_SETUP([system variables - $DATE $DATE11 $JDATE $TIME])
+AT_KEYWORDS([expression expressions parse])
+# Get the date in the formats that $DATE and $DATE11 support.
+date=$(date +%d-%^b-%y)
+date11=$(date +%d-%^b-%Y)
+echo "date=$date" # Should be date=DD-MMM-YY.
+echo "date11=$date11" # Should be date11=DD-MMM-YYYY.
+
+# Maybe we don't have the 'date' program or it doesn't work as we
+# expect. Check by trying to see if $date and $date11 are in the
+# expected format. If not, skip the test.
+AS_CASE([$date],
+ [[[0-9][0-9]-[A-Z][A-Z][A-Z]-[0-9][0-9]]], [],
+ [AT_SKIP_IF([:])])
+AS_CASE([$date11],
+ [[[0-9][0-9]-[A-Z][A-Z][A-Z]-[0-9][0-9][0-9][0-9]]], [],
+ [AT_SKIP_IF([:])])
+
+AT_DATA([parse.sps], [dnl
+DEBUG EVALUATE /$DATE.
+DEBUG EVALUATE /$DATE11.
+DEBUG EVALUATE FORMAT=DATE9 /$JDATE * 86400.
+DEBUG EVALUATE FORMAT=DATE9 /$TIME.
+])
+AT_CHECK_UNQUOTED([pspp --testing-mode parse.sps], [0], [dnl
+\$DATE => "$date"
+
+\$DATE11 => "$date11"
+
+\$JDATE * 86400 => $date
+
+\$TIME => $date
+])
+AT_CLEANUP
+
+AT_SETUP([expressions - negative checks])
+AT_KEYWORDS([expression expressions parse])
+AT_DATA([evaluate-base.sps], [dnl
+SET EPOCH 1940.
+DEBUG EVALUATE SET opt.
+DEBUG EVALUATE /$nonexistent.
+DEBUG EVALUATE /RANGE(1, 2).
+DEBUG EVALUATE /CONCAT.1('a', 'b').
+DEBUG EVALUATE /foobar(x).
+DEBUG EVALUATE /CONCAT.1('a' b).
+DEBUG EVALUATE /NCDF.CHISQ(1, 2, 3).
+DEBUG EVALUATE (a=1)(b=2) VECTOR/v('abc').
+])
+
+for opt in OPT NOOPT; do
+ AS_BOX([$opt])
+ sed "s/opt/$opt/" < evaluate-base.sps > evaluate.sps
+ AT_CHECK([pspp --testing-mode evaluate.sps], [1],
+[[evaluate.sps:3: error: DEBUG EVALUATE: Unknown system variable $nonexistent.
+
+$nonexistent => error
+
+evaluate.sps:4.17-4.27: error: DEBUG EVALUATE: RANGE(number, number, number[,
+number, number]...) must have an odd number of arguments.
+ 4 | DEBUG EVALUATE /RANGE(1, 2).
+ | ^~~~~~~~~~~
+
+RANGE(1, 2) => error
+
+evaluate.sps:5.17-5.34: error: DEBUG EVALUATE: CONCAT(string[, string]...)
+function cannot accept suffix .1 to specify the minimum number of valid
+arguments.
+ 5 | DEBUG EVALUATE /CONCAT.1('a', 'b').
+ | ^~~~~~~~~~~~~~~~~~
+
+CONCAT.1('a', 'b') => error
+
+evaluate.sps:6: error: DEBUG EVALUATE: No function or vector named foobar.
+
+foobar(x) => error
+
+evaluate.sps:7.30: error: DEBUG EVALUATE: Syntax error at `b': expecting `,' or
+`)'.
+
+CONCAT.1('a' b) => error
+
+evaluate.sps:8.17-8.35: error: DEBUG EVALUATE: NCDF.CHISQ(number, number,
+number) is not available in this version of PSPP.
+ 8 | DEBUG EVALUATE /NCDF.CHISQ(1, 2, 3).
+ | ^~~~~~~~~~~~~~~~~~~
+
+NCDF.CHISQ(1, 2, 3) => error
+
+evaluate.sps:9.34-9.41: error: DEBUG EVALUATE: A vector index must be numeric.
+ 9 | DEBUG EVALUATE (a=1)(b=2) VECTOR/v('abc').
+ | ^~~~~~~~
+
+evaluate.sps:9.36-9.40: note: DEBUG EVALUATE: This vector index has type
+'string'.
+ 9 | DEBUG EVALUATE (a=1)(b=2) VECTOR/v('abc').
+ | ^~~~~
+
+v('abc') => error
+]])
+done
+AT_CLEANUP