Add copyright and licence notices to files which lack them.
[pspp] / tests / data / por-file.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([portable files])
17
18 AT_SETUP([overwriting portable file])
19 AT_DATA([output.por], [abcdef
20 ])
21 cp output.por output.por.backup
22 AT_DATA([porfile.sps], [dnl
23 DATA LIST NOTABLE/x 1.
24 BEGIN DATA.
25 5
26 END DATA.
27 EXPORT OUTFILE='output.por'.
28 ])
29 AT_CHECK([pspp -O format=csv porfile.sps])
30 AT_CHECK([cmp output.por output.por.backup], [1], [ignore])
31 AT_CLEANUP
32
33 AT_SETUP([overwriting portable file atomically])
34 AT_DATA([output.por], [abcdef
35 ])
36 cp output.por output.por.backup
37 AT_DATA([porfile.sps],
38 [[DATA LIST NOTABLE/x 1.
39 BEGIN DATA.
40 5
41 END DATA.
42 XEXPORT OUTFILE='output.por'.
43 HOST COMMAND=['kill -TERM $PPID'].
44 ]])
45 AT_CHECK([pspp -O format=csv porfile.sps], [143], [], [ignore])
46 AT_CHECK([cmp output.por output.por.backup])
47 AT_CHECK(
48   [for file in *.tmp*; do if test -e $file; then echo $file; exit 1; fi; done])
49 AT_CLEANUP
50
51 AT_SETUP([write to same portable file being read])
52 AT_DATA([export.sps], [dnl
53 DATA LIST NOTABLE/x 1.
54 BEGIN DATA.
55 2
56 END DATA.
57 EXPORT OUTFILE='data.por'.
58 ])
59 AT_CHECK([pspp -O format=csv export.sps])
60 AT_CHECK([test -s data.por])
61 AT_CHECK(
62   [for file in *.tmp*; do if test -e $file; then echo $file; exit 1; fi; done])
63 AT_DATA([export2.sps], [dnl
64 IMPORT FILE='data.por'.
65 COMPUTE y = x * 2.
66 EXPORT OUTFILE='data.por'.
67 ])
68 AT_CHECK([pspp -O format=csv export2.sps])
69 AT_CHECK(
70   [for file in *.tmp*; do if test -e $file; then echo $file; exit 1; fi; done])
71 AT_DATA([export3.sps], [dnl
72 IMPORT FILE='data.por'.
73 LIST.
74 ])
75 AT_CHECK([pspp -O format=csv export3.sps], [0], [dnl
76 Table: Data List
77 X,Y
78 2,4.00
79 ])
80 AT_CLEANUP
81
82 dnl This checks for a bug in the portable file writer that caused an infinite
83 dnl loop in some cases, and other problems in other cases, when a variable
84 dnl had value labels.
85 AT_SETUP([write portable file with value labels])
86 AT_DATA([export.sps], [dnl
87 DATA LIST NOTABLE/var1 TO var5 1-5.
88 VALUE LABELS
89         /var1 1 'one'
90         /var2 2 'two'
91         /var3 3 'three'
92         /var4 4 'four'
93         /var5 5 'five'.
94 BEGIN DATA.
95 12345
96 END DATA.
97 EXPORT OUTFILE='data.por'.
98 ])
99 AT_CHECK([pspp -O format=csv export.sps])
100 AT_DATA([import.sps], [dnl
101 IMPORT FILE='data.por'.
102 DISPLAY DICTIONARY.
103 LIST.
104 ])
105 AT_CHECK([pspp -O format=csv import.sps], [0], [dnl
106 Variable,Description,Position
107 VAR1,"Format: F1.0
108
109 Value,Label
110 1,one",1
111 VAR2,"Format: F1.0
112
113 Value,Label
114 2,two",2
115 VAR3,"Format: F1.0
116
117 Value,Label
118 3,three",3
119 VAR4,"Format: F1.0
120
121 Value,Label
122 4,four",4
123 VAR5,"Format: F1.0
124
125 Value,Label
126 5,five",5
127
128 Table: Data List
129 VAR1,VAR2,VAR3,VAR4,VAR5
130 1,2,3,4,5
131 ])
132 AT_DATA([sys-file-info.sps], [SYSFILE INFO FILE='data.por'
133 ])
134 AT_CHECK([pspp -O format=csv sys-file-info.sps | sed '/Encoding/d
135 /Integer Format/d
136 /Real Format/d
137 /Created/d
138 /Product/d
139 '], [0], [dnl
140 File:,data.por
141 Label:,No label.
142 Variables:,5
143 Cases:,Unknown
144 Type:,SPSS Portable File
145 Weight:,Not weighted.
146 Compression:,None
147
148 Variable,Description,Position
149 VAR1,"Format: F1.0
150 Measure: Scale
151 Role: Input
152 Display Alignment: Right
153 Display Width: 8
154
155 Value,Label
156 1,one",1
157 VAR2,"Format: F1.0
158 Measure: Scale
159 Role: Input
160 Display Alignment: Right
161 Display Width: 8
162
163 Value,Label
164 2,two",2
165 VAR3,"Format: F1.0
166 Measure: Scale
167 Role: Input
168 Display Alignment: Right
169 Display Width: 8
170
171 Value,Label
172 3,three",3
173 VAR4,"Format: F1.0
174 Measure: Scale
175 Role: Input
176 Display Alignment: Right
177 Display Width: 8
178
179 Value,Label
180 4,four",4
181 VAR5,"Format: F1.0
182 Measure: Scale
183 Role: Input
184 Display Alignment: Right
185 Display Width: 8
186
187 Value,Label
188 5,five",5
189 ])
190 AT_CLEANUP