Merge remote-tracking branch 'origin/master' into sheet
[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 DISPLAY DICTIONARY
79 ])
80 AT_CHECK([pspp -o pspp.csv missing-values.sps])
81 AT_CHECK([sed -n '/^$/p; /^@<:@^"@:>@*"@<:@^"@:>@*$/N; s/^\(@<:@a-z0-9@:>@*\),".*Missing Values: \(.*\)",@<:@0-9@:>@*$/\1: \2/p; s/^\(@<:@a-z0-9@:>@*\),Format: @<:@A-Z0-9.@:>@*,@<:@0-9@:>@*$/\1: none/p' pspp.csv
82 ], [0], [dnl
83 date1: 1
84 num1: 1
85
86 date1: 1; 2
87 num1: 1; 2
88
89 date1: 1; 2; 3
90 num1: 1; 2; 3
91
92 date1: 9999998; 9999984; 3
93 num1: 9999998; 9999984; 3
94
95 date1: 1
96 num1: 1
97
98 date1: 1; 2
99 num1: 1; 2
100
101 date1: 1; 2; 3
102 num1: 1; 2; 3
103
104 date1: 13342665600
105 num1: 13342665600
106
107 date1: 13342665600; 12495427200
108 num1: 13342665600; 12495427200
109
110 date1: 13342665600; 12495427200; 12570336000
111 num1: 13342665600; 12495427200; 12570336000
112
113 num1: 1 THRU 2
114
115 num1: LOWEST THRU 2
116
117 num1: LOWEST THRU 2
118
119 num1: 1 THRU HIGHEST
120
121 num1: 1 THRU HIGHEST
122
123 num1: 1 THRU 2; 3
124
125 num1: LOWEST THRU 2; 3
126
127 num1: LOWEST THRU 2; 3
128
129 num1: 1 THRU HIGHEST; -1
130
131 num1: 1 THRU HIGHEST; -1
132
133 str1: ""abc  ""; ""def  ""
134 str2: ""abc""; ""def""
135 longstr: ""abc     ""; ""def     ""
136
137 str1: none
138 str2: none
139 date1: none
140 num1: none
141 longstr: none
142 ])
143 AT_CLEANUP
144
145 AT_SETUP([MISSING VALUES invalid cases])
146 AT_DATA([missing-values.sps], [dnl
147 DATA LIST NOTABLE/str1 1-5 (A) str2 6-8 (A) date1 9-19 (DATE) num1 20-25
148                   longstr 26-36 (A).
149
150 * Too long for str2.
151 MISSING VALUES str1 str2 longstr ('abcde').
152
153 * Long string missing value longer than 8 bytes.
154 MISSING VALUES longstr ('abcdefghijk').
155
156 * No string ranges.
157 MISSING VALUES str1 ('a' THRU 'z').
158
159 * Mixing string and numeric variables.
160 MISSING VALUES str1 num1 ('123').
161
162 * Too many values.
163 MISSING VALUES num1 (1, 2, 3, 4).
164 MISSING VALUES num1 (1 THRU 2, 3 THRU 4).
165 MISSING VALUES num1 (1, 2 THRU 3, 4).
166 MISSING VALUES str1 ('abc', 'def', 'ghi', 'jkl').
167
168 * Bad range.
169 MISSING VALUES num1 (2 THRU 1).
170 ])
171 AT_CHECK([pspp -O format=csv missing-values.sps], [1], [dnl
172 missing-values.sps:5: error: MISSING VALUES: Missing values provided are too long to assign to variable of width 3.
173
174 missing-values.sps:8: error: MISSING VALUES: Truncating missing value to maximum acceptable length (8 bytes).
175
176 missing-values.sps:11.26-11.29: error: MISSING VALUES: Syntax error at `THRU': expecting string.
177
178 missing-values.sps:11: error: MISSING VALUES: THRU is not a variable name.
179
180 missing-values.sps:14: error: MISSING VALUES: Cannot mix numeric variables (e.g. num1) and string variables (e.g. str1) within a single list.
181
182 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.
183
184 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.
185
186 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.
187
188 missing-values.sps:20: error: MISSING VALUES: Too many string missing values.  At most three individual values are allowed.
189
190 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.
191 ])
192 AT_CLEANUP