Merge remote-tracking branch 'origin/master' into sheet
[pspp] / tests / language / lexer / command-name.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([command name matching])
18 \f
19 AT_SETUP([single words])
20 AT_KEYWORDS([command name matching])
21 AT_CHECK([command-name-test DESCRIPTIVES , DESCRIPTIVESX DESCRIPTIVES descr Des DEX DE '' 'DESCRIPTIVES MORE' 'DESCRIPTIVES@<00A0>@MORE'],
22   [0], [dnl
23 string="DESCRIPTIVESX":
24         command="DESCRIPTIVES" match=no
25 match: none, missing_words=0
26
27 string="DESCRIPTIVES":
28         command="DESCRIPTIVES" match=yes exact=yes missing_words=0
29 match: DESCRIPTIVES, missing_words=0
30
31 string="descr":
32         command="DESCRIPTIVES" match=yes exact=no missing_words=0
33 match: DESCRIPTIVES, missing_words=0
34
35 string="Des":
36         command="DESCRIPTIVES" match=yes exact=no missing_words=0
37 match: DESCRIPTIVES, missing_words=0
38
39 string="DEX":
40         command="DESCRIPTIVES" match=no
41 match: none, missing_words=0
42
43 string="DE":
44         command="DESCRIPTIVES" match=no
45 match: none, missing_words=0
46
47 string="":
48         command="DESCRIPTIVES" match=yes exact=yes missing_words=1
49 match: none, missing_words=1
50
51 string="DESCRIPTIVES MORE":
52         command="DESCRIPTIVES" match=yes exact=yes missing_words=-1
53 match: DESCRIPTIVES, missing_words=-1
54
55 string="DESCRIPTIVES@<00A0>@MORE":
56         command="DESCRIPTIVES" match=yes exact=yes missing_words=-1
57 match: DESCRIPTIVES, missing_words=-1
58 ])
59 AT_CLEANUP
60 \f
61 AT_SETUP([two words without prefix match])
62 AT_KEYWORDS([command name matching])
63 AT_CHECK([command-name-test 'DO IF' 'DO REPEAT' , 'DO@<00A0>@IF' 'DO REPEAT' 'DO REP' 'DO OTHER' 'D IF' 'DO I' DO],
64   [0], [dnl
65 string="DO@<00A0>@IF":
66         command="DO IF" match=yes exact=yes missing_words=0
67         command="DO REPEAT" match=no
68 match: DO IF, missing_words=0
69
70 string="DO REPEAT":
71         command="DO IF" match=no
72         command="DO REPEAT" match=yes exact=yes missing_words=0
73 match: DO REPEAT, missing_words=0
74
75 string="DO REP":
76         command="DO IF" match=no
77         command="DO REPEAT" match=yes exact=no missing_words=0
78 match: DO REPEAT, missing_words=0
79
80 string="DO OTHER":
81         command="DO IF" match=no
82         command="DO REPEAT" match=no
83 match: none, missing_words=0
84
85 string="D IF":
86         command="DO IF" match=no
87         command="DO REPEAT" match=no
88 match: none, missing_words=0
89
90 string="DO I":
91         command="DO IF" match=no
92         command="DO REPEAT" match=no
93 match: none, missing_words=0
94
95 string="DO":
96         command="DO IF" match=yes exact=yes missing_words=1
97         command="DO REPEAT" match=yes exact=yes missing_words=1
98 match: none, missing_words=1
99 ])
100 AT_CLEANUP
101 \f
102 AT_SETUP([two words with prefix match])
103 AT_KEYWORDS([command name matching])
104 AT_CHECK([command-name-test GET 'GET DATA' , GET 'GET TYPE' 'GET DAT' 'GET DATA'],
105   [0], [dnl
106 string="GET":
107         command="GET" match=yes exact=yes missing_words=0
108         command="GET DATA" match=yes exact=yes missing_words=1
109 match: none, missing_words=1
110
111 string="GET TYPE":
112         command="GET" match=yes exact=yes missing_words=-1
113         command="GET DATA" match=no
114 match: GET, missing_words=-1
115
116 string="GET DAT":
117         command="GET" match=yes exact=yes missing_words=-1
118         command="GET DATA" match=yes exact=no missing_words=0
119 match: GET DATA, missing_words=0
120
121 string="GET DATA":
122         command="GET" match=yes exact=yes missing_words=-1
123         command="GET DATA" match=yes exact=yes missing_words=0
124 match: GET DATA, missing_words=0
125 ])
126 AT_CLEANUP
127 \f
128 AT_SETUP([ambiguous single-word names])
129 AT_KEYWORDS([command name matching])
130 AT_CHECK([command-name-test CASEPLOT CASESTOVARS , CAS Case CaseP CaseS], [0],
131   [dnl
132 string="CAS":
133         command="CASEPLOT" match=yes exact=no missing_words=0
134         command="CASESTOVARS" match=yes exact=no missing_words=0
135 match: none, missing_words=0
136
137 string="Case":
138         command="CASEPLOT" match=yes exact=no missing_words=0
139         command="CASESTOVARS" match=yes exact=no missing_words=0
140 match: none, missing_words=0
141
142 string="CaseP":
143         command="CASEPLOT" match=yes exact=no missing_words=0
144         command="CASESTOVARS" match=no
145 match: CASEPLOT, missing_words=0
146
147 string="CaseS":
148         command="CASEPLOT" match=no
149         command="CASESTOVARS" match=yes exact=no missing_words=0
150 match: CASESTOVARS, missing_words=0
151 ])
152 AT_CLEANUP
153
154 AT_SETUP([ambiguous two-word names])
155 AT_KEYWORDS([command name matching])
156 AT_CHECK([command-name-test VARCOMP VARSTOCASES 'VARIABLE ATTRIBUTE' , VAR VARC VARS VARI 'VAR@<00A0>@ATT'],
157   [0], [dnl
158 string="VAR":
159         command="VARCOMP" match=yes exact=no missing_words=0
160         command="VARSTOCASES" match=yes exact=no missing_words=0
161         command="VARIABLE ATTRIBUTE" match=yes exact=no missing_words=1
162 match: none, missing_words=1
163
164 string="VARC":
165         command="VARCOMP" match=yes exact=no missing_words=0
166         command="VARSTOCASES" match=no
167         command="VARIABLE ATTRIBUTE" match=no
168 match: VARCOMP, missing_words=0
169
170 string="VARS":
171         command="VARCOMP" match=no
172         command="VARSTOCASES" match=yes exact=no missing_words=0
173         command="VARIABLE ATTRIBUTE" match=no
174 match: VARSTOCASES, missing_words=0
175
176 string="VARI":
177         command="VARCOMP" match=no
178         command="VARSTOCASES" match=no
179         command="VARIABLE ATTRIBUTE" match=yes exact=no missing_words=1
180 match: none, missing_words=1
181
182 string="VAR@<00A0>@ATT":
183         command="VARCOMP" match=yes exact=no missing_words=-1
184         command="VARSTOCASES" match=yes exact=no missing_words=-1
185         command="VARIABLE ATTRIBUTE" match=yes exact=no missing_words=0
186 match: VARIABLE ATTRIBUTE, missing_words=0
187 ])
188 AT_CLEANUP
189 \f
190 AT_SETUP([numbers and punctuation])
191 AT_KEYWORDS([command name matching])
192 AT_CHECK([command-name-test T-TEST 2SLS LIST , T-TEST 'T - Test' 2SLS '2 SLS' List],
193   [0], [dnl
194 string="T-TEST":
195         command="T-TEST" match=yes exact=yes missing_words=0
196         command="2SLS" match=no
197         command="LIST" match=no
198 match: T-TEST, missing_words=0
199
200 string="T - Test":
201         command="T-TEST" match=yes exact=yes missing_words=0
202         command="2SLS" match=no
203         command="LIST" match=no
204 match: T-TEST, missing_words=0
205
206 string="2SLS":
207         command="T-TEST" match=no
208         command="2SLS" match=yes exact=yes missing_words=0
209         command="LIST" match=no
210 match: 2SLS, missing_words=0
211
212 string="2 SLS":
213         command="T-TEST" match=no
214         command="2SLS" match=yes exact=yes missing_words=0
215         command="LIST" match=no
216 match: 2SLS, missing_words=0
217
218 string="List":
219         command="T-TEST" match=no
220         command="2SLS" match=no
221         command="LIST" match=yes exact=yes missing_words=0
222 match: LIST, missing_words=0
223 ])
224 AT_CLEANUP
225 \f
226 AT_SETUP([off by more than one word])
227 AT_KEYWORDS([command name matching])
228 AT_CHECK([command-name-test 'a@<00A0>@b c' , a 'a b' 'a b c' 'a@<00A0>@b c d' 'a b c@<00A0>@d e'],
229   [0], [dnl
230 string="a":
231         command="a@<00A0>@b c" match=yes exact=yes missing_words=2
232 match: none, missing_words=1
233
234 string="a b":
235         command="a@<00A0>@b c" match=yes exact=yes missing_words=1
236 match: none, missing_words=1
237
238 string="a b c":
239         command="a@<00A0>@b c" match=yes exact=yes missing_words=0
240 match: a@<00A0>@b c, missing_words=0
241
242 string="a@<00A0>@b c d":
243         command="a@<00A0>@b c" match=yes exact=yes missing_words=-1
244 match: a@<00A0>@b c, missing_words=-1
245
246 string="a b c@<00A0>@d e":
247         command="a@<00A0>@b c" match=yes exact=yes missing_words=-2
248 match: a@<00A0>@b c, missing_words=-2
249 ])
250 AT_CLEANUP