output: Introduce pivot tables.
[pspp] / tests / language / expressions / evaluate.at
index 41104dd70b422d8287da58c604647a10d21ca340..76e11d885eb256b35ebd450f2c5b1d7059fbf8f5 100644 (file)
@@ -1,4 +1,19 @@
-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.
@@ -352,8 +367,19 @@ RND(number, number, number).]],
   [[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]],
@@ -633,7 +659,7 @@ MIN(string[, string]...).]],
   [[min("1", "2")], ["1"]],
   [[min("1")], ["1"]])
 
-CHECK_EXPR_EVAL([cfvar mean sd sum variance],
+CHECK_EXPR_EVAL([cfvar mean median sd sum variance],
   [[cfvar(1, 2, 3, 4, 5)], [0.53]],
   [[cfvar(1, $sysmis, 2, 3, $sysmis, 4, 5)], [0.53]],
   [[cfvar(1, 2)], [0.47]],
@@ -661,6 +687,25 @@ CHECK_EXPR_EVAL([cfvar mean sd sum variance],
   [[mean.4(1, 2, 3)], [error],
    [error: DEBUG EVALUATE: With MEAN(number[, number]...), using minimum valid argument count of 4 does not make sense when passing only 3 arguments in list.]],
 
+  [[median(1, 2, 3, 4, 5)], [3.00]],
+  [[median(2, 3, 4, 5, 1)], [3.00]],
+  [[median(2, 3, 4, 1, 5)], [3.00]],
+  [[median(2, 1, 4, 5, 3)], [3.00]],
+  [[median(1, 2, 3, 4)], [2.50]],
+  [[median(2, 3, 1, 4)], [2.50]],
+  [[median(2, 3, 4, 1)], [2.50]],
+  [[median(2, 1, 4, 3)], [2.50]],
+  [[median(1, $sysmis, 3, 4, 5)], [3.50]],
+  [[median(2, 3, 4, 5, $sysmis, 1)], [3.00]],
+  [[median($sysmis, $sysmis, $sysmis, 2, 3, 4, 1, 5)], [3.00]],
+  [[median(1, 2, 3)], [2.00]],
+  [[median(1)], [1.00]],
+  [[median(1, 2)], [1.50]],
+  [[median(1, 2, $sysmis)], [1.50]],
+  [[median(1, $sysmis, $sysmis)], [1.00]],
+  [[median($sysmis, $sysmis, $sysmis)], [sysmis]],
+  [[median.3(1, 2, $sysmis)], [sysmis]],
+  [[median.2(1, $sysmis)], [sysmis]],
 
   [[sd(1, 2, 3, 4, 5)], [1.58]],
   [[sd(1, $sysmis, 2, 3, $sysmis, 4, 5)], [1.58]],
@@ -825,7 +870,7 @@ CHECK_EXPR_EVAL([replace],
   [[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"]],
@@ -981,6 +1026,29 @@ dnl E has a minimum width of 6 on output:
    [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"]],
@@ -2052,10 +2120,10 @@ Table: Data List
 n,s,nlabel,slabel
 .,,,
 0,a,Very dissa,Wouldn't b
-1,b,Dissatisfi,Unhappy   @&t@
-2,c,Neutral   ,Bored     @&t@
-3,d,Satisfied ,Satiated  @&t@
-4,e,Very satis,Elated    @&t@
+1,b,Dissatisfi,Unhappy
+2,c,Neutral,Bored
+3,d,Satisfied,Satiated
+4,e,Very satis,Elated
 5,f,,
 6,g,,
 ])