Add copyright and licence notices to files which lack them.
[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 AT_BANNER([COMPUTE transformation])
17
18 AT_SETUP([COMPUTE crash with SAVE])
19 AT_DATA([compute.sps],
20   [INPUT PROGRAM.
21 COMPUTE num = 3.
22 END FILE.
23 END INPUT PROGRAM.
24 EXECUTE.
25
26 SAVE outfile='temp.sav'.
27 ])
28 AT_CHECK([pspp -O format=csv compute.sps])
29 AT_DATA([list.sps],
30   [GET FILE='temp.sav'.
31 LIST.
32 ])
33 AT_CHECK([pspp -O format=csv list.sps], [0], 
34   [])
35 AT_CLEANUP
36
37 AT_SETUP([COMPUTE bug in long string UPCASE])
38 AT_DATA([compute.sps],
39   [DATA LIST LIST
40  /A (A161)
41  B (A3).
42
43 BEGIN DATA
44 abc   def
45 ghi   jkl
46 END DATA.
47
48 COMPUTE A=upcase(A).
49 EXECUTE.
50 LIST.
51 ])
52 AT_CHECK([pspp -O format=csv compute.sps], [0],
53   [Table: Reading free-form data from INLINE.
54 Variable,Format
55 A,A161
56 B,A3
57
58 Table: Data List
59 A,B
60 ABC                                                                                                                                                              ,def
61 GHI                                                                                                                                                              ,jkl
62 ])
63 AT_CLEANUP
64
65 AT_SETUP([COMPUTE bug with long variable names])
66 AT_DATA([compute.sps],
67   [DATA LIST LIST /longVariablename * x *.
68 BEGIN DATA.
69 1 2
70 3 4
71 END DATA.
72
73
74 COMPUTE longvariableName=100-longvariablename.
75
76 LIST.
77 ])
78 AT_CHECK([pspp -O format=csv compute.sps], [0],
79   [Table: Reading free-form data from INLINE.
80 Variable,Format
81 longVariablename,F8.0
82 x,F8.0
83
84 Table: Data List
85 longVariablename,x
86 99.00,2.00
87 97.00,4.00
88 ])
89 AT_CLEANUP
90
91 AT_SETUP([COMPUTE self-reference to new variable])
92 AT_DATA([compute.sps],
93   [DATA LIST /ITEM 1-3.
94 COMPUTE SUM=SUM+ITEM.
95 PRINT OUTFILE='compute-sum.out' /ITEM SUM.
96 LEAVE SUM
97 BEGIN DATA.
98 123
99 404
100 555
101 999
102 END DATA.
103 ])
104 AT_CHECK([pspp -O format=csv compute.sps], [0],
105   [Table: Reading 1 record from INLINE.
106 Variable,Record,Columns,Format
107 ITEM,1,1-  3,F3.0
108 ])
109 AT_CHECK([cat compute-sum.out], [0],
110   [ 123   123.00 @&t@
111  404   527.00 @&t@
112  555  1082.00 @&t@
113  999  2081.00 @&t@
114 ])
115 AT_CLEANUP