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