-m4_define([CHECK_EXPR_EVAL],
+dnl PSPP - a program for statistical analysis.
+dnl Copyright (C) 2017 Free Software Foundation, Inc.
+dnl
+dnl This program is free software: you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation, either version 3 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
+dnl m4_define([CHECK_EXPR_EVAL],
[AT_SETUP([expressions - $1])
AT_DATA([evaluate.sps],
[set mxwarn 1000.
[[trunc(1.9)], [1.00]],
[[trunc(-1.2)], [-1.00]],
[[trunc(-1.9)], [-1.00]],
+ [[trunc(5.06, .1)], [5.00]],
+ [[trunc(-5.06, .1)], [-5.00]],
+ [[trunc(1)], [1.00]],
+ [[trunc(1 - 2**-53)], [1.00]],
+ [[trunc(1 - 2**-52)], [1.00]],
+ [[trunc(1 - 2**-51)], [1.00]],
+ [[trunc(1 - 2**-45)], [0.00]],
+ [[trunc(1 - 2**-45, 1, 10)], [1.00]],
[[trunc('x')], [error],
- [error: DEBUG EVALUATE: Type mismatch invoking TRUNC(number) as trunc(string).]])
+ [error: DEBUG EVALUATE: Function invocation trunc(string) does not match any known function. Candidates are:
+TRUNC(number)
+TRUNC(number, number)
+TRUNC(number, number, number).]])
CHECK_EXPR_EVAL([acos arsin artan cos sin tan],
[[acos(.5) / 3.14159 * 180], [60.00]],
[[replace('banana', 'ba', '', -1)], ["banana"]],
[[replace('banana', 'ba', '', $sysmis)], ["banana"]])
-CHECK_EXPR_EVAL([lpad number ltrim lpad rtrim rpad string substr upcase],
+CHECK_EXPR_EVAL([lpad number ltrim lpad rtrim rpad string strunc substr upcase],
[[lpad('abc', -1)], [""]],
[[lpad('abc', 0)], ["abc"]],
[[lpad('abc', 2)], ["abc"]],
[error: DEBUG EVALUATE: Type mismatch invoking STRING(number, num_output_format) as string(number, format).]],
[[string(123, e6.0)], ["1E+002"]],
+ [[strunc('a c ', 9)], ["a c"]],
+ [[strunc('a c ', 7)], ["a c"]],
+ [[strunc('a c ', 6)], ["a c"]],
+ [[strunc('a c ', 5)], ["a c"]],
+ [[strunc('a c ', 4)], ["a c"]],
+ [[strunc('a c ', 3)], ["a c"]],
+ [[strunc('a c ', 2)], ["a"]],
+ [[strunc('a c ', 1)], ["a"]],
+ [[strunc('a c ', 0)], [""]],
+ [[strunc('a c ', -1)], [""]],
+ [[strunc('a c ', $sysmis)], [""]],
+ [[strunc(' abc ', 9)], [" abc"]],
+ [[strunc(' abc ', 8)], [" abc"]],
+ [[strunc(' abc ', 7)], [" abc"]],
+ [[strunc(' abc ', 6)], [" abc"]],
+ [[strunc(' abc ', 5)], [" abc"]],
+ [[strunc(' abc ', 4)], [" ab"]],
+ [[strunc(' abc ', 3)], [" a"]],
+ [[strunc(' abc ', 2)], [""]],
+ [[strunc(' abc ', 1)], [""]],
+ [[strunc(' abc ', -1)], [""]],
+ [[strunc(' abc ', $sysmis)], [""]],
+
[[substr('abcdefgh', -5)], [""]],
[[substr('abcdefgh', 0)], [""]],
[[substr('abcdefgh', 1)], ["abcdefgh"]],