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