1dnl PSPP - a program for statistical analysis.
2dnl Copyright (C) 2017 Free Software Foundation, Inc.
3dnl
4dnl This program is free software: you can redistribute it and/or modify
5dnl it under the terms of the GNU General Public License as published by
6dnl the Free Software Foundation, either version 3 of the License, or
7dnl (at your option) any later version.
8dnl
9dnl This program is distributed in the hope that it will be useful,
10dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12dnl GNU General Public License for more details.
13dnl
14dnl You should have received a copy of the GNU General Public License
15dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
16dnl
17AT_BANNER([MISSING VALUES])
18
19AT_SETUP([MISSING VALUES valid cases])
20AT_DATA([missing-values.sps], [dnl
21DATA 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.
25MISSING VALUES date1 num1 (1).
26DISPLAY DICTIONARY date1 num1.
27MISSING VALUES date1 num1 (1, 2).
28DISPLAY DICTIONARY date1 num1.
29MISSING VALUES date1 num1 (1, 2, 3).
30DISPLAY DICTIONARY date1 num1.
31MISSING VALUES date1 num1 (9999998, 9999984, 3).
32DISPLAY DICTIONARY date1 num1.
33
34* Numeric missing values using the first variable's format.
35MISSING VALUES num1 date1 ('1').
36DISPLAY DICTIONARY date1 num1.
37MISSING VALUES num1 date1 ('1', '2').
38DISPLAY DICTIONARY date1 num1.
39MISSING VALUES num1 date1 ('1', '2', '3').
40DISPLAY DICTIONARY date1 num1.
41MISSING VALUES date1 num1 ('06-AUG-05').
42DISPLAY DICTIONARY date1 num1.
43MISSING VALUES date1 num1 ('06-AUG-05', '01-OCT-78').
44DISPLAY DICTIONARY date1 num1.
45MISSING VALUES date1 num1 ('06-AUG-05', '01-OCT-78', '14-FEB-81').
46DISPLAY DICTIONARY date1 num1.
47
48* Ranges of numeric missing values.
49MISSING VALUES num1 (1 THRU 2).
50DISPLAY DICTIONARY num1.
51MISSING VALUES num1 (LO THRU 2).
52DISPLAY DICTIONARY num1.
53MISSING VALUES num1 (LOWEST THRU 2).
54DISPLAY DICTIONARY num1.
55MISSING VALUES num1 (1 THRU HI).
56DISPLAY DICTIONARY num1.
57MISSING VALUES num1 (1 THRU HIGHEST).
58DISPLAY DICTIONARY num1.
59
60* A range of numeric missing values, plus an individual value.
61MISSING VALUES num1 (1 THRU 2, 3).
62DISPLAY DICTIONARY num1.
63MISSING VALUES num1 (LO THRU 2, 3).
64DISPLAY DICTIONARY num1.
65MISSING VALUES num1 (LOWEST THRU 2, 3).
66DISPLAY DICTIONARY num1.
67MISSING VALUES num1 (1 THRU HI, -1).
68DISPLAY DICTIONARY num1.
69MISSING VALUES num1 (1 THRU HIGHEST, -1).
70DISPLAY DICTIONARY num1.
71
72* String missing values.
73MISSING VALUES str1 str2 longstr ('abc  ','def').
74DISPLAY DICTIONARY str1 str2 longstr.
75
76* May mix variable types when clearing missing values.
77MISSING VALUES ALL ().
78DISPLAY DICTIONARY
79])
80AT_CHECK([pspp -o pspp.csv missing-values.sps])
81AT_CHECK([cat pspp.csv | sed '/^Table/d
82/^Name/d
83s/^\([[a-z0-9]]*\),.*,\([[^,]]*\)$/\1: \2/'], [0], [dnl
84date1: 1
85num1: 1
86
87date1: 1; 2
88num1: 1; 2
89
90date1: 1; 2; 3
91num1: 1; 2; 3
92
93date1: 9999998; 9999984; 3
94num1: 9999998; 9999984; 3
95
96date1: 1
97num1: 1
98
99date1: 1; 2
100num1: 1; 2
101
102date1: 1; 2; 3
103num1: 1; 2; 3
104
105date1: 13342665600
106num1: 13342665600
107
108date1: 13342665600; 12495427200
109num1: 13342665600; 12495427200
110
111date1: 13342665600; 12495427200; 12570336000
112num1: 13342665600; 12495427200; 12570336000
113
114num1: 1 THRU 2
115
116num1: LOWEST THRU 2
117
118num1: LOWEST THRU 2
119
120num1: 1 THRU HIGHEST
121
122num1: 1 THRU HIGHEST
123
124num1: 1 THRU 2; 3
125
126num1: LOWEST THRU 2; 3
127
128num1: LOWEST THRU 2; 3
129
130num1: 1 THRU HIGHEST; -1
131
132num1: 1 THRU HIGHEST; -1
133
134str1: """abc  ""; ""def  """
135str2: """abc""; ""def"""
136longstr: """abc     ""; ""def     """
137
138str1: @&t@
139str2: @&t@
140date1: @&t@
141num1: @&t@
142longstr: @&t@
143])
144AT_CLEANUP
145
146AT_SETUP([MISSING VALUES invalid cases])
147AT_DATA([missing-values.sps], [dnl
148DATA LIST NOTABLE/str1 1-5 (A) str2 6-8 (A) date1 9-19 (DATE) num1 20-25
149                  longstr 26-36 (A).
150
151* Too long for str2.
152MISSING VALUES str1 str2 longstr ('abcde').
153
154* Long string missing value longer than 8 bytes.
155MISSING VALUES longstr ('abcdefghijk').
156
157* No string ranges.
158MISSING VALUES str1 ('a' THRU 'z').
159
160* Mixing string and numeric variables.
161MISSING VALUES str1 num1 ('123').
162
163* Too many values.
164MISSING VALUES num1 (1, 2, 3, 4).
165MISSING VALUES num1 (1 THRU 2, 3 THRU 4).
166MISSING VALUES num1 (1, 2 THRU 3, 4).
167MISSING VALUES str1 ('abc', 'def', 'ghi', 'jkl').
168
169* Bad range.
170MISSING VALUES num1 (2 THRU 1).
171])
172AT_CHECK([pspp -O format=csv missing-values.sps], [1], [dnl
173missing-values.sps:5: error: MISSING VALUES: Missing values provided are too long to assign to variable of width 3.
174
175missing-values.sps:8: error: MISSING VALUES: Truncating missing value to maximum acceptable length (8 bytes).
176
177missing-values.sps:11.26-11.29: error: MISSING VALUES: Syntax error at `THRU': expecting string.
178
179missing-values.sps:11: error: MISSING VALUES: THRU is not a variable name.
180
181missing-values.sps:14: error: MISSING VALUES: Cannot mix numeric variables (e.g. num1) and string variables (e.g. str1) within a single list.
182
183missing-values.sps:17: error: MISSING VALUES: Too many numeric missing values.  At most three individual values or one value and one range are allowed.
184
185missing-values.sps:18: error: MISSING VALUES: Too many numeric missing values.  At most three individual values or one value and one range are allowed.
186
187missing-values.sps:19: error: MISSING VALUES: Too many numeric missing values.  At most three individual values or one value and one range are allowed.
188
189missing-values.sps:20: error: MISSING VALUES: Too many string missing values.  At most three individual values are allowed.
190
191missing-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.
192])
193AT_CLEANUP
194