output: Introduce pivot tables.
[pspp] / tests / language / xforms / compute.at
1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
3 dnl 
4 dnl This program is free software: you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation, either version 3 of the License, or
7 dnl (at your option) any later version.
8 dnl 
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 dnl GNU General Public License for more details.
13 dnl 
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 dnl
17 AT_BANNER([COMPUTE transformation])
18
19 AT_SETUP([COMPUTE crash with SAVE])
20 AT_DATA([compute.sps],
21   [INPUT PROGRAM.
22 COMPUTE num = 3.
23 END FILE.
24 END INPUT PROGRAM.
25 EXECUTE.
26
27 SAVE outfile='temp.sav'.
28 ])
29 AT_CHECK([pspp -O format=csv compute.sps])
30 AT_DATA([list.sps],
31   [GET FILE='temp.sav'.
32 LIST.
33 ])
34 AT_CHECK([pspp -O format=csv list.sps], [0], 
35   [])
36 AT_CLEANUP
37
38 AT_SETUP([COMPUTE bug in long string UPCASE])
39 AT_DATA([compute.sps],
40   [DATA LIST LIST
41  /A (A161)
42  B (A3).
43
44 BEGIN DATA
45 abc   def
46 ghi   jkl
47 END DATA.
48
49 COMPUTE A=upcase(A).
50 EXECUTE.
51 LIST.
52 ])
53 AT_CHECK([pspp -O format=csv compute.sps], [0],
54   [Table: Reading free-form data from INLINE.
55 Variable,Format
56 A,A161
57 B,A3
58
59 Table: Data List
60 A,B
61 ABC,def
62 GHI,jkl
63 ])
64 AT_CLEANUP
65
66 AT_SETUP([COMPUTE bug with long variable names])
67 AT_DATA([compute.sps],
68   [DATA LIST LIST /longVariablename * x *.
69 BEGIN DATA.
70 1 2
71 3 4
72 END DATA.
73
74
75 COMPUTE longvariableName=100-longvariablename.
76
77 LIST.
78 ])
79 AT_CHECK([pspp -O format=csv compute.sps], [0],
80   [Table: Reading free-form data from INLINE.
81 Variable,Format
82 longVariablename,F8.0
83 x,F8.0
84
85 Table: Data List
86 longVariablename,x
87 99.00,2.00
88 97.00,4.00
89 ])
90 AT_CLEANUP
91
92 AT_SETUP([COMPUTE self-reference to new variable])
93 AT_DATA([compute.sps],
94   [DATA LIST /ITEM 1-3.
95 COMPUTE SUM=SUM+ITEM.
96 PRINT OUTFILE='compute-sum.out' /ITEM SUM.
97 LEAVE SUM
98 BEGIN DATA.
99 123
100 404
101 555
102 999
103 END DATA.
104 ])
105 AT_CHECK([pspp -O format=csv compute.sps], [0],
106   [Table: Reading 1 record from INLINE.
107 Variable,Record,Columns,Format
108 ITEM,1,1-  3,F3.0
109 ])
110 AT_CHECK([cat compute-sum.out], [0],
111   [ 123   123.00 @&t@
112  404   527.00 @&t@
113  555  1082.00 @&t@
114  999  2081.00 @&t@
115 ])
116 AT_CLEANUP