f462b1fe2b132af4733131ec411f3beff86954d2
[pspp] / tests / language / stats / flip.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([FLIP command])
18
19 AT_SETUP([FLIP with NEWNAMES])
20 AT_DATA([flip.sps], [dnl
21 data list notable /N 1 (a) a b c d 2-9.
22 list.
23 begin data.
24 v 1 2 3 4 5
25 w 6 7 8 910
26 x1112131415
27 y1617181920
28 z2122232425
29 end data.
30 temporary.
31 compute e = a.
32 flip newnames=n.
33 list.
34 flip.
35 list.
36 ])
37 AT_CHECK([pspp -O format=csv flip.sps], [0], [dnl
38 Table: Data List
39 N,a,b,c,d
40 v,1,2,3,4
41 w,6,7,8,9
42 x,11,12,13,14
43 y,16,17,18,19
44 z,21,22,23,24
45
46 "flip.sps:12.1-12.4: warning: FLIP: FLIP ignores TEMPORARY.  Temporary transformations will be made permanent.
47    12 | flip newnames=n.
48       | ^~~~"
49
50 Table: Data List
51 CASE_LBL,v,w,x,y,z
52 a,1.00,6.00,11.00,16.00,21.00
53 b,2.00,7.00,12.00,17.00,22.00
54 c,3.00,8.00,13.00,18.00,23.00
55 d,4.00,9.00,14.00,19.00,24.00
56 e,1.00,6.00,11.00,16.00,21.00
57
58 Table: Data List
59 CASE_LBL,a,b,c,d,e
60 v,1.00,2.00,3.00,4.00,1.00
61 w,6.00,7.00,8.00,9.00,6.00
62 x,11.00,12.00,13.00,14.00,11.00
63 y,16.00,17.00,18.00,19.00,16.00
64 z,21.00,22.00,23.00,24.00,21.00
65 ])
66 AT_CLEANUP
67
68 AT_SETUP([FLIP without NEWNAMES])
69 AT_DATA([flip.sps], [dnl
70 data list list notable /v1 to v10.
71 format all(f2).
72 begin data.
73 1 2 3 4 5 6 7 8 9 10
74 4 5 6 7 8 9 10 11 12 13
75 end data.
76
77 list.
78
79 flip.
80 list.
81 ])
82 AT_CHECK([pspp -O format=csv flip.sps], [0], [dnl
83 Table: Data List
84 v1,v2,v3,v4,v5,v6,v7,v8,v9,v10
85 1,2,3,4,5,6,7,8,9,10
86 4,5,6,7,8,9,10,11,12,13
87
88 Table: Data List
89 CASE_LBL,VAR000,VAR001
90 v1,1.00,4.00
91 v2,2.00,5.00
92 v3,3.00,6.00
93 v4,4.00,7.00
94 v5,5.00,8.00
95 v6,6.00,9.00
96 v7,7.00,10.00
97 v8,8.00,11.00
98 v9,9.00,12.00
99 v10,10.00,13.00
100 ])
101 AT_CLEANUP
102
103
104
105
106 AT_SETUP([FLIP badly formed])
107
108 AT_DATA([flip.sps], [dnl
109 data list notable /N 1 (a) a b c d 2-9.
110
111 flip newnames=n.
112 list.
113 flip.
114 ])
115
116 AT_CHECK([pspp -O format=csv flip.sps], [1], [ignore])
117
118 AT_CLEANUP
119
120
121
122 AT_SETUP([FLIP with invalid variable names])
123
124 AT_DATA([flip.sps], [dnl
125 data list notable list /N (a3) a b c d *.
126 begin data.
127 ""   1  2  3  4
128 BY   1  2  3  4
129 end data.
130
131 flip newnames=n.
132
133 list.
134 ])
135
136 AT_CHECK([pspp -O format=csv flip.sps], [0], [dnl
137 Table: Data List
138 CASE_LBL,v,BY1
139 a,1.00,1.00
140 b,2.00,2.00
141 c,3.00,3.00
142 d,4.00,4.00
143 ])
144
145 AT_CLEANUP