Move all command implementations into a single 'commands' directory.
[pspp] / tests / language / commands / compute.at
diff --git a/tests/language/commands/compute.at b/tests/language/commands/compute.at
new file mode 100644 (file)
index 0000000..65ca4af
--- /dev/null
@@ -0,0 +1,116 @@
+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
+AT_BANNER([COMPUTE transformation])
+
+AT_SETUP([COMPUTE crash with SAVE])
+AT_DATA([compute.sps],
+  [INPUT PROGRAM.
+COMPUTE num = 3.
+END FILE.
+END INPUT PROGRAM.
+EXECUTE.
+
+SAVE outfile='temp.sav'.
+])
+AT_CHECK([pspp -O format=csv compute.sps])
+AT_DATA([list.sps],
+  [GET FILE='temp.sav'.
+LIST.
+])
+AT_CHECK([pspp -O format=csv list.sps], [0],
+  [])
+AT_CLEANUP
+
+AT_SETUP([COMPUTE bug in long string UPCASE])
+AT_DATA([compute.sps],
+  [DATA LIST LIST
+ /A (A161)
+ B (A3).
+
+BEGIN DATA
+abc   def
+ghi   jkl
+END DATA.
+
+COMPUTE A=upcase(A).
+EXECUTE.
+LIST.
+])
+AT_CHECK([pspp -O format=csv compute.sps], [0],
+  [Table: Reading free-form data from INLINE.
+Variable,Format
+A,A161
+B,A3
+
+Table: Data List
+A,B
+ABC,def
+GHI,jkl
+])
+AT_CLEANUP
+
+AT_SETUP([COMPUTE bug with long variable names])
+AT_DATA([compute.sps],
+  [DATA LIST LIST /longVariablename * x *.
+BEGIN DATA.
+1 2
+3 4
+END DATA.
+
+
+COMPUTE longvariableName=100-longvariablename.
+
+LIST.
+])
+AT_CHECK([pspp -O format=csv compute.sps], [0],
+  [Table: Reading free-form data from INLINE.
+Variable,Format
+longVariablename,F8.0
+x,F8.0
+
+Table: Data List
+longVariablename,x
+99.00,2.00
+97.00,4.00
+])
+AT_CLEANUP
+
+AT_SETUP([COMPUTE self-reference to new variable])
+AT_DATA([compute.sps],
+  [DATA LIST /ITEM 1-3.
+COMPUTE SUM=SUM+ITEM.
+PRINT OUTFILE='compute-sum.out' /ITEM SUM.
+LEAVE SUM
+BEGIN DATA.
+123
+404
+555
+999
+END DATA.
+])
+AT_CHECK([pspp -O format=csv compute.sps], [0],
+  [Table: Reading 1 record from INLINE.
+Variable,Record,Columns,Format
+ITEM,1,1-3,F3.0
+])
+AT_CHECK([cat compute-sum.out], [0],
+  [ 123   123.00 @&t@
+ 404   527.00 @&t@
+ 555  1082.00 @&t@
+ 999  2081.00 @&t@
+])
+AT_CLEANUP