pivot-table: Change the default format to omit empty rows and columns.
[pspp] / tests / language / dictionary / missing-values.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([MISSING VALUES])
18
19 AT_SETUP([MISSING VALUES valid cases])
20 AT_DATA([missing-values.sps], [dnl
21 DATA LIST NOTABLE/str1 1-5 (A) str2 6-8 (A) date1 9-19 (DATE) num1 20-25
22                   longstr 26-36 (A).
23
24 * Numeric missing values.
25 MISSING VALUES date1 num1 (1).
26 DISPLAY DICTIONARY date1 num1.
27 MISSING VALUES date1 num1 (1, 2).
28 DISPLAY DICTIONARY date1 num1.
29 MISSING VALUES date1 num1 (1, 2, 3).
30 DISPLAY DICTIONARY date1 num1.
31 MISSING VALUES date1 num1 (9999998, 9999984, 3).
32 DISPLAY DICTIONARY date1 num1.
33
34 * Numeric missing values using the first variable's format.
35 MISSING VALUES num1 date1 ('1').
36 DISPLAY DICTIONARY date1 num1.
37 MISSING VALUES num1 date1 ('1', '2').
38 DISPLAY DICTIONARY date1 num1.
39 MISSING VALUES num1 date1 ('1', '2', '3').
40 DISPLAY DICTIONARY date1 num1.
41 MISSING VALUES date1 num1 ('06-AUG-05').
42 DISPLAY DICTIONARY date1 num1.
43 MISSING VALUES date1 num1 ('06-AUG-05', '01-OCT-78').
44 DISPLAY DICTIONARY date1 num1.
45 MISSING VALUES date1 num1 ('06-AUG-05', '01-OCT-78', '14-FEB-81').
46 DISPLAY DICTIONARY date1 num1.
47
48 * Ranges of numeric missing values.
49 MISSING VALUES num1 (1 THRU 2).
50 DISPLAY DICTIONARY num1.
51 MISSING VALUES num1 (LO THRU 2).
52 DISPLAY DICTIONARY num1.
53 MISSING VALUES num1 (LOWEST THRU 2).
54 DISPLAY DICTIONARY num1.
55 MISSING VALUES num1 (1 THRU HI).
56 DISPLAY DICTIONARY num1.
57 MISSING VALUES num1 (1 THRU HIGHEST).
58 DISPLAY DICTIONARY num1.
59
60 * A range of numeric missing values, plus an individual value.
61 MISSING VALUES num1 (1 THRU 2, 3).
62 DISPLAY DICTIONARY num1.
63 MISSING VALUES num1 (LO THRU 2, 3).
64 DISPLAY DICTIONARY num1.
65 MISSING VALUES num1 (LOWEST THRU 2, 3).
66 DISPLAY DICTIONARY num1.
67 MISSING VALUES num1 (1 THRU HI, -1).
68 DISPLAY DICTIONARY num1.
69 MISSING VALUES num1 (1 THRU HIGHEST, -1).
70 DISPLAY DICTIONARY num1.
71
72 * String missing values.
73 MISSING VALUES str1 str2 longstr ('abc  ','def').
74 DISPLAY DICTIONARY str1 str2 longstr.
75
76 * May mix variable types when clearing missing values.
77 MISSING VALUES ALL ().
78 MISSING VALUES num1 (1).
79 DISPLAY DICTIONARY
80 ])
81 AT_CHECK([pspp -o pspp.csv missing-values.sps])
82 AT_CHECK([cat pspp.csv | sed '/^Table/d
83 /^Name/d
84 s/^\([[a-z0-9]]*\),.*,\([[^,]]*\)$/\1: \2/'], [0], [dnl
85 date1: 1
86 num1: 1
87
88 date1: 1; 2
89 num1: 1; 2
90
91 date1: 1; 2; 3
92 num1: 1; 2; 3
93
94 date1: 9999998; 9999984; 3
95 num1: 9999998; 9999984; 3
96
97 date1: 1
98 num1: 1
99
100 date1: 1; 2
101 num1: 1; 2
102
103 date1: 1; 2; 3
104 num1: 1; 2; 3
105
106 date1: 13342665600
107 num1: 13342665600
108
109 date1: 13342665600; 12495427200
110 num1: 13342665600; 12495427200
111
112 date1: 13342665600; 12495427200; 12570336000
113 num1: 13342665600; 12495427200; 12570336000
114
115 num1: 1 THRU 2
116
117 num1: LOWEST THRU 2
118
119 num1: LOWEST THRU 2
120
121 num1: 1 THRU HIGHEST
122
123 num1: 1 THRU HIGHEST
124
125 num1: 1 THRU 2; 3
126
127 num1: LOWEST THRU 2; 3
128
129 num1: LOWEST THRU 2; 3
130
131 num1: 1 THRU HIGHEST; -1
132
133 num1: 1 THRU HIGHEST; -1
134
135 str1: """abc  ""; ""def  """
136 str2: """abc""; ""def"""
137 longstr: """abc     ""; ""def     """
138
139 str1: @&t@
140 str2: @&t@
141 date1: @&t@
142 num1: 1
143 longstr: @&t@
144 ])
145 AT_CLEANUP
146
147 AT_SETUP([MISSING VALUES invalid cases])
148 AT_DATA([missing-values.sps], [dnl
149 DATA LIST NOTABLE/str1 1-5 (A) str2 6-8 (A) date1 9-19 (DATE) num1 20-25
150                   longstr 26-36 (A).
151
152 * Too long for str2.
153 MISSING VALUES str1 str2 longstr ('abcde').
154
155 * Long string missing value longer than 8 bytes.
156 MISSING VALUES longstr ('abcdefghijk').
157
158 * No string ranges.
159 MISSING VALUES str1 ('a' THRU 'z').
160
161 * Mixing string and numeric variables.
162 MISSING VALUES str1 num1 ('123').
163
164 * Too many values.
165 MISSING VALUES num1 (1, 2, 3, 4).
166 MISSING VALUES num1 (1 THRU 2, 3 THRU 4).
167 MISSING VALUES num1 (1, 2 THRU 3, 4).
168 MISSING VALUES str1 ('abc', 'def', 'ghi', 'jkl').
169
170 * Bad range.
171 MISSING VALUES num1 (2 THRU 1).
172 ])
173 AT_CHECK([pspp -O format=csv missing-values.sps], [1], [dnl
174 missing-values.sps:5: error: MISSING VALUES: Missing values provided are too long to assign to variable of width 3.
175
176 missing-values.sps:8: error: MISSING VALUES: Truncating missing value to maximum acceptable length (8 bytes).
177
178 missing-values.sps:11.26-11.29: error: MISSING VALUES: Syntax error at `THRU': expecting string.
179
180 missing-values.sps:11: error: MISSING VALUES: THRU is not a variable name.
181
182 missing-values.sps:14: error: MISSING VALUES: Cannot mix numeric variables (e.g. num1) and string variables (e.g. str1) within a single list.
183
184 missing-values.sps:17: error: MISSING VALUES: Too many numeric missing values.  At most three individual values or one value and one range are allowed.
185
186 missing-values.sps:18: error: MISSING VALUES: Too many numeric missing values.  At most three individual values or one value and one range are allowed.
187
188 missing-values.sps:19: error: MISSING VALUES: Too many numeric missing values.  At most three individual values or one value and one range are allowed.
189
190 missing-values.sps:20: error: MISSING VALUES: Too many string missing values.  At most three individual values are allowed.
191
192 missing-values.sps:23: warning: MISSING VALUES: The high end of the range (1) is below the low end (2).  The range will be treated as if reversed.
193 ])
194 AT_CLEANUP