53bec038232d2b0ce76abe72401c998e3e2c1ec3
[pspp] / tests / language / dictionary / rename-variables.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([RENAME VARIABLES])
18
19 AT_SETUP([RENAME VARIABLES])
20 AT_DATA([rename-variables.sps], [dnl
21 DATA LIST LIST /brakeFluid y auxiliary warp (F2.0).
22 BEGIN DATA.
23 1 3 5 9
24 2 3 6 10
25 3 3 7 11
26 4 3 8 11
27 END DATA.
28
29 LIST.
30
31 RENAME VARIABLES brakeFluid=applecarts y=bananamobiles.
32 RENAME VARIABLES (warp auxiliary=foobar xyzzy).
33
34 LIST.
35
36 SAVE /OUTFILE='rename.sav'.
37 ])
38 AT_CHECK([pspp -O format=csv rename-variables.sps], [0], [dnl
39 Table: Reading free-form data from INLINE.
40 Variable,Format
41 brakeFluid,F2.0
42 y,F2.0
43 auxiliary,F2.0
44 warp,F2.0
45
46 Table: Data List
47 brakeFluid,y,auxiliary,warp
48 1,3,5,9
49 2,3,6,10
50 3,3,7,11
51 4,3,8,11
52
53 Table: Data List
54 applecarts,bananamobiles,xyzzy,foobar
55 1,3,5,9
56 2,3,6,10
57 3,3,7,11
58 4,3,8,11
59 ])
60 AT_CHECK([grep '[bB][rR][aA][kK][eE]' rename.sav], [1], [ignore-nolog])
61 AT_CLEANUP
62
63
64 AT_SETUP([RENAME VARIABLES -- multiple sets])
65 AT_DATA([rename-variables.sps], [dnl
66 data list list /a b c d  e *.
67 begin data.
68 1 2 3 4 5
69 end data.
70
71 rename variables (a b=x y) (c d e=z zz zzz).
72
73 list.
74 ])
75
76 AT_CHECK([pspp -O format=csv rename-variables.sps], [0], [dnl
77 Table: Reading free-form data from INLINE.
78 Variable,Format
79 a,F8.0
80 b,F8.0
81 c,F8.0
82 d,F8.0
83 e,F8.0
84
85 Table: Data List
86 x,y,z,zz,zzz
87 1.00,2.00,3.00,4.00,5.00
88 ])
89
90 AT_CLEANUP
91
92
93 AT_SETUP([RENAME VARIABLES -- invalid syntax 1])
94
95 AT_DATA([rename-variables.sps], [dnl
96 DATA LIST LIST /brakeFluid y auxiliary warp (F2.0).
97 RENAME VARIABLES warp auxiliary=foobar xyzzy.
98 ])
99
100 AT_CHECK([pspp -o pspp.csv rename-variables.sps], [1], [dnl
101 rename-variables.sps:2.23-2.31: error: RENAME VARIABLES: Syntax error at `auxiliary': expecting `='.
102 ])
103 AT_CLEANUP
104
105 AT_SETUP([RENAME VARIABLES -- invalid syntax 2])
106 AT_DATA([rename-variables.sps], [dnl
107 DATA LIST LIST /brakeFluid y auxiliary warp (F2.0).
108 RENAME VARIABLES (brakeFluid=applecarts y=bananamobiles).
109 ])
110
111 AT_CHECK([pspp -o pspp.csv rename-variables.sps], [1], [dnl
112 rename-variables.sps:2: error: RENAME VARIABLES: Differing number of variables in old name list (1) and in new name list (2).
113 ])
114 AT_CLEANUP
115
116
117
118
119 AT_SETUP([RENAME VARIABLES -- invalid syntax 3])
120 AT_DATA([rename-variables.sps], [dnl
121 DATA LIST NOTABLE LIST /z y p q (F2.0).
122 BEGIN DATA.
123 4 3 8 11
124 END DATA.
125
126 RENAME VARIABLES z=a y}bqnanamobiles.
127
128 LIST.
129 ])
130
131 AT_CHECK([pspp -O format=csv rename-variables.sps], [1], [ignore])
132
133
134 AT_CLEANUP