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