Commit | Line | Data |
---|---|---|
6a3c6ee4 PA |
1 | # Copyright 2017 Free Software Foundation, Inc. |
2 | ||
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation; either version 3 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | # This file is part of the gdb testsuite. | |
17 | ||
18 | load_lib completion-support.exp | |
19 | ||
20 | standard_testfile cpls-ops.cc | |
21 | ||
22 | if {[prepare_for_testing "failed to prepare" $testfile \ | |
23 | [list $srcfile] {debug}]} { | |
24 | return -1 | |
25 | } | |
26 | ||
27 | gdb_test_no_output "set max-completions unlimited" | |
28 | ||
29 | # Check that the explicit location completer manages to find the next | |
30 | # option name after a "-function function" option. A useful test when | |
31 | # the -function options's argument is a C++ operator, which can | |
32 | # include characters like '-'. | |
33 | ||
34 | proc check_explicit_skips_function_argument {function} { | |
35 | test_gdb_complete_unique \ | |
36 | "b -function $function -sour" \ | |
37 | "b -function $function -source" | |
38 | } | |
39 | ||
40 | # Helper function for the operator new/new[] tests. CLASS_NAME is the | |
41 | # name of the class that contains the operator we're testing. | |
42 | # BRACKETS is set to [] if testing operator new[], and to empty if | |
43 | # testing operator new. | |
44 | ||
45 | proc test_operator_new {class_name brackets} { | |
46 | # The type size_t is typedef-ed to. | |
47 | set size_t "unsigned long" | |
48 | ||
49 | # Complete all prefixes between "operato" and the full prototype. | |
50 | foreach cmd_prefix {"b" "b -function"} { | |
51 | set location "${class_name}::operator new${brackets}($size_t)" | |
52 | set line "$cmd_prefix $location" | |
53 | set start [index_after "operato" $line] | |
54 | test_complete_prefix_range $line $start | |
55 | check_bp_locations_match_list "$cmd_prefix $location" [list $location] | |
56 | ||
57 | # Same, but with extra spaces. Note that the original spaces in | |
58 | # the input line are preserved after completion. | |
59 | ||
60 | test_gdb_complete_unique \ | |
61 | "$cmd_prefix ${class_name}::operator new " \ | |
62 | "$cmd_prefix ${class_name}::operator new ${brackets}($size_t)" | |
63 | test_gdb_complete_unique \ | |
64 | "$cmd_prefix ${class_name}::operator new ${brackets} (" \ | |
65 | "$cmd_prefix ${class_name}::operator new ${brackets} ($size_t)" | |
66 | test_gdb_complete_unique \ | |
67 | "$cmd_prefix ${class_name}::operator new ${brackets} ( $size_t " \ | |
68 | "$cmd_prefix ${class_name}::operator new ${brackets} ( $size_t )" | |
69 | ||
70 | check_setting_bp_fails "$cmd_prefix ${class_name}::operator" | |
71 | ||
72 | set location_list \ | |
73 | [list \ | |
74 | "${class_name}::operator new${brackets}" \ | |
75 | "${class_name}::operator new${brackets} ($size_t)" \ | |
76 | "${class_name}::operator new ${brackets} ( $size_t )"] | |
77 | foreach linespec $location_list { | |
78 | check_bp_locations_match_list \ | |
79 | "$cmd_prefix $linespec" [list $location] | |
80 | } | |
81 | } | |
82 | ||
83 | # Check that the explicit location completer manages to find the | |
84 | # option name after -function, when the -function's argument is a | |
85 | # C++ operator new / new[]. | |
86 | check_explicit_skips_function_argument \ | |
87 | "${class_name}::operator new ${brackets} ( $size_t )" | |
88 | } | |
89 | ||
90 | proc_with_prefix operator-new {} { | |
91 | test_operator_new test_op_new "" | |
92 | } | |
93 | ||
94 | proc_with_prefix operator-new\[\] {} { | |
95 | test_operator_new test_op_new_array "\[\]" | |
96 | } | |
97 | ||
98 | # Helper function for the operator delete/delete[] tests. CLASS_NAME | |
99 | # is the name of the class that contains the operator we're testing. | |
100 | # BRACKETS is set to "[]" if testing operator delete[], and to empty | |
101 | # if testing operator delete. | |
102 | ||
103 | proc test_operator_delete {class_name brackets} { | |
104 | # Complete all prefixes between "operato" and the full prototype. | |
105 | foreach cmd_prefix {"b" "b -function"} { | |
106 | set location "${class_name}::operator delete${brackets}(void*)" | |
107 | set line "$cmd_prefix $location" | |
108 | set start [index_after "operato" $line] | |
109 | test_complete_prefix_range $line $start | |
110 | check_bp_locations_match_list "$cmd_prefix $location" [list $location] | |
111 | ||
112 | # Same, but with extra spaces. Note that the original spaces in | |
113 | # the input line are preserved after completion. | |
114 | ||
115 | test_gdb_complete_unique \ | |
116 | "$cmd_prefix ${class_name}::operator delete " \ | |
117 | "$cmd_prefix ${class_name}::operator delete ${brackets}(void*)" | |
118 | test_gdb_complete_unique \ | |
119 | "$cmd_prefix ${class_name}::operator delete ${brackets} (" \ | |
120 | "$cmd_prefix ${class_name}::operator delete ${brackets} (void*)" | |
121 | test_gdb_complete_unique \ | |
122 | "$cmd_prefix ${class_name}::operator delete ${brackets} ( void* " \ | |
123 | "$cmd_prefix ${class_name}::operator delete ${brackets} ( void* )" | |
124 | test_gdb_complete_unique \ | |
125 | "$cmd_prefix ${class_name}::operator delete ${brackets} ( void * " \ | |
126 | "$cmd_prefix ${class_name}::operator delete ${brackets} ( void * )" | |
127 | ||
128 | check_setting_bp_fails "$cmd_prefix ${class_name}::operator" | |
129 | ||
130 | set location_list \ | |
131 | [list \ | |
132 | "${class_name}::operator delete${brackets}" \ | |
133 | "${class_name}::operator delete${brackets}(void *)" \ | |
134 | "${class_name}::operator delete ${brackets} ( void * )"] | |
135 | foreach linespec $location_list { | |
136 | check_bp_locations_match_list \ | |
137 | "$cmd_prefix $linespec" [list $location] | |
138 | } | |
139 | } | |
140 | ||
141 | # Check that the explicit location completer manages to find the | |
142 | # option name after -function, when the -function's argument is a | |
143 | # C++ operator delete / delete[]. | |
144 | check_explicit_skips_function_argument \ | |
145 | "${class_name}::operator delete ${brackets} ( void * )" | |
146 | } | |
147 | ||
148 | proc_with_prefix operator-delete {} { | |
149 | test_operator_delete test_op_delete "" | |
150 | } | |
151 | ||
152 | proc_with_prefix operator-delete\[\] {} { | |
153 | test_operator_delete test_op_delete_array "\[\]" | |
154 | } | |
155 | ||
156 | # Helper for testing both operator() and operator[]. Tests completion | |
157 | # when the operator match is unique. CLASS_NAME is the class that | |
158 | # holds the operator to test. OPN and CLS are the open and close | |
159 | # characters ("()" or "[]"). | |
160 | ||
161 | proc test_operator_unique {class_name opn cls} { | |
162 | # Complete all prefixes between "oper" and the full prototype. | |
163 | foreach cmd_prefix {"b" "b -function"} { | |
164 | set location "${class_name}::operator${opn}${cls}(int)" | |
165 | set line "$cmd_prefix $location" | |
166 | set start [index_after "${class_name}" $line] | |
167 | test_complete_prefix_range $line $start | |
168 | check_bp_locations_match_list "$cmd_prefix $location" [list $location] | |
169 | ||
170 | # Same, but with extra spaces. Note that the original spaces in | |
171 | # the input line are preserved after completion. | |
172 | ||
173 | test_gdb_complete_unique \ | |
174 | "$cmd_prefix ${class_name}::operator ${opn} ${cls} ( int " \ | |
175 | "$cmd_prefix ${class_name}::operator ${opn} ${cls} ( int )" | |
176 | test_gdb_complete_unique \ | |
177 | "$cmd_prefix ${class_name}::operator ${opn} ${cls}" \ | |
178 | "$cmd_prefix ${class_name}::operator ${opn} ${cls}(int)" | |
179 | test_gdb_complete_unique \ | |
180 | "$cmd_prefix ${class_name}::operator ${opn}${cls}" \ | |
181 | "$cmd_prefix ${class_name}::operator ${opn}${cls}(int)" | |
182 | test_gdb_complete_unique \ | |
183 | "$cmd_prefix ${class_name}::operator ${opn}" \ | |
184 | "$cmd_prefix ${class_name}::operator ${opn}${cls}(int)" | |
185 | ||
186 | check_setting_bp_fails "$cmd_prefix ${class_name}::operator" | |
187 | ||
188 | set location_list \ | |
189 | [list \ | |
190 | "${class_name}::operator${opn}${cls}" \ | |
191 | "${class_name}::operator ${opn}${cls}" \ | |
192 | "${class_name}::operator ${opn}${cls}(int)" \ | |
193 | "${class_name}::operator ${opn} ${cls} ( int )"] | |
194 | foreach linespec $location_list { | |
195 | check_bp_locations_match_list \ | |
196 | "$cmd_prefix $linespec" [list $location] | |
197 | } | |
198 | } | |
199 | ||
200 | # Check that the explicit location completer manages to find the | |
201 | # option name after -function, when the -function's argument is a | |
202 | # C++ operator(). | |
203 | check_explicit_skips_function_argument \ | |
204 | "${class_name}::operator ${opn} ${cls} ( int )" | |
205 | } | |
206 | ||
207 | # Helper for testing both operator() and operator[]. Tests completion | |
208 | # when the operator match is ambiguous. CLASS_NAME is the class that | |
209 | # holds the operator to test. OPN and CLS are the open and close | |
210 | # characters ("()" or "[]"). | |
211 | ||
212 | proc test_operator_ambiguous {class_name opn cls} { | |
213 | foreach cmd_prefix {"b" "b -function"} { | |
214 | check_setting_bp_fails "$cmd_prefix ${class_name}::operator" | |
215 | ||
216 | set linespec_noparams "${class_name}::operator${opn}${cls}" | |
217 | ||
218 | set location_list \ | |
219 | [list \ | |
220 | "${class_name}::operator${opn}${cls}(int)" \ | |
221 | "${class_name}::operator${opn}${cls}(long)" \ | |
222 | "${class_name}::operator${opn}${cls}<int>(int*)"] | |
223 | # The operator[] test can't have a "()" overload, since that | |
224 | # wouldn't compile. | |
225 | if {$opn == "("} { | |
226 | set location_list \ | |
227 | [concat \ | |
228 | [list "${class_name}::operator${opn}${cls}()"] \ | |
229 | $location_list] | |
230 | } | |
231 | test_gdb_complete_multiple \ | |
232 | "$cmd_prefix " "$linespec_noparams" "" $location_list | |
233 | ||
234 | # Setting the breakpoint doesn't create a breakpoint location | |
235 | # for the template, because immediately after | |
236 | # "operator()/operator[]" we have the template parameters, not | |
237 | # the parameter list. | |
238 | set location_list \ | |
239 | [list \ | |
240 | "${class_name}::operator${opn}${cls}(int)" \ | |
241 | "${class_name}::operator${opn}${cls}(long)"] | |
242 | if {$opn == "("} { | |
243 | set location_list \ | |
244 | [concat \ | |
245 | [list "${class_name}::operator${opn}${cls}()"] \ | |
246 | $location_list] | |
247 | } | |
248 | check_bp_locations_match_list "$cmd_prefix $linespec_noparams" \ | |
249 | $location_list | |
250 | check_bp_locations_match_list "$cmd_prefix $linespec_noparams<int>" \ | |
251 | [list "${class_name}::operator${opn}${cls}<int>(int*)"] | |
252 | ||
253 | # Test the template version. Test both with and without | |
254 | # return type. | |
255 | test_gdb_complete_unique \ | |
256 | "$cmd_prefix ${class_name}::operator${opn}${cls}<int>(in" \ | |
257 | "$cmd_prefix ${class_name}::operator${opn}${cls}<int>(int*)" | |
258 | check_bp_locations_match_list \ | |
259 | "$cmd_prefix ${class_name}::operator${opn}${cls}<int>(int*)" \ | |
260 | [list "${class_name}::operator${opn}${cls}<int>(int*)"] | |
261 | test_gdb_complete_unique \ | |
262 | "$cmd_prefix void ${class_name}::operator${opn}${cls}<int>(in" \ | |
263 | "$cmd_prefix void ${class_name}::operator${opn}${cls}<int>(int*)" | |
264 | check_bp_locations_match_list \ | |
265 | "$cmd_prefix void ${class_name}::operator${opn}${cls}<int>(int*)" \ | |
266 | [list "${class_name}::operator${opn}${cls}<int>(int*)"] | |
267 | ||
268 | # Add extra spaces. | |
269 | test_gdb_complete_unique \ | |
270 | "$cmd_prefix ${class_name}::operator ${opn} ${cls} ( in" \ | |
271 | "$cmd_prefix ${class_name}::operator ${opn} ${cls} ( int)" | |
272 | check_bp_locations_match_list \ | |
273 | "$cmd_prefix ${class_name}::operator ${opn} ${cls} ( int )" \ | |
274 | [list "${class_name}::operator${opn}${cls}(int)"] | |
275 | } | |
276 | } | |
277 | ||
278 | proc_with_prefix operator()-unique {} { | |
279 | test_operator_unique test_unique_op_call "(" ")" | |
280 | } | |
281 | ||
282 | proc_with_prefix operator\[\]-unique {} { | |
283 | test_operator_unique test_unique_op_array "\[" "\]" | |
284 | } | |
285 | ||
286 | proc_with_prefix operator()-ambiguous {} { | |
287 | test_operator_ambiguous test_op_call "(" ")" | |
288 | } | |
289 | ||
290 | proc_with_prefix operator\[\]-ambiguous {} { | |
291 | test_operator_ambiguous test_op_array "\[" "\]" | |
292 | } | |
293 | ||
294 | # Test arithmetic/logical operators. Test completing all C++ | |
295 | # arithmetic/logical operators, when all the operators are in the same | |
296 | # class. | |
297 | ||
298 | proc_with_prefix ops-valid-ambiguous {} { | |
299 | set locations { | |
300 | "test_ops::operator!(E)" | |
301 | "test_ops::operator!=(E, E)" | |
302 | "test_ops::operator%(E, E)" | |
303 | "test_ops::operator%=(E, E)" | |
304 | "test_ops::operator&&(E, E)" | |
305 | "test_ops::operator&(E, E)" | |
306 | "test_ops::operator&=(E, E)" | |
307 | "test_ops::operator*(E, E)" | |
308 | "test_ops::operator*=(E, E)" | |
309 | "test_ops::operator+(E, E)" | |
310 | "test_ops::operator++(E)" | |
311 | "test_ops::operator++(E, int)" | |
312 | "test_ops::operator+=(E, E)" | |
313 | "test_ops::operator,(E, E)" | |
314 | "test_ops::operator-(E, E)" | |
315 | "test_ops::operator--(E)" | |
316 | "test_ops::operator--(E, int)" | |
317 | "test_ops::operator-=(E, E)" | |
318 | "test_ops::operator/(E, E)" | |
319 | "test_ops::operator/=(E, E)" | |
320 | "test_ops::operator<(E, E)" | |
321 | "test_ops::operator<<(E, E)" | |
322 | "test_ops::operator<<=(E, E)" | |
323 | "test_ops::operator<=(E, E)" | |
324 | "test_ops::operator==(E, E)" | |
325 | "test_ops::operator>(E, E)" | |
326 | "test_ops::operator>=(E, E)" | |
327 | "test_ops::operator>>(E, E)" | |
328 | "test_ops::operator>>=(E, E)" | |
329 | "test_ops::operator^(E, E)" | |
330 | "test_ops::operator^=(E, E)" | |
331 | "test_ops::operator|(E, E)" | |
332 | "test_ops::operator|=(E, E)" | |
333 | "test_ops::operator||(E, E)" | |
334 | "test_ops::operator~(E)" | |
335 | } | |
336 | foreach linespec $locations { | |
337 | foreach cmd_prefix {"b" "b -function"} { | |
338 | test_gdb_complete_unique \ | |
339 | "$cmd_prefix $linespec" \ | |
340 | "$cmd_prefix $linespec" | |
341 | ||
342 | } | |
343 | ||
344 | check_explicit_skips_function_argument "$linespec" | |
345 | } | |
346 | ||
347 | foreach cmd_prefix {"b" "b -function"} { | |
348 | test_gdb_complete_multiple \ | |
349 | "$cmd_prefix " "test_ops::operator" "" $locations | |
350 | } | |
351 | } | |
352 | ||
353 | # Test completing all C++ operators, with and without spaces. The | |
354 | # test without spaces makes sure the completion matches exactly the | |
355 | # expected prototype. The version with whitespace is a bit more lax | |
356 | # for simplicity. In that case, we only make sure we get back the | |
357 | # terminating ')'. Each operator is defined in a separate class so | |
358 | # that we can exercise unique completion matches. | |
359 | ||
360 | proc_with_prefix ops-valid-unique {} { | |
361 | set locations { | |
362 | "test_op_BIT_AND::operator&(E, E)" | |
363 | "test_op_BIT_AND_A::operator&=(E, E)" | |
364 | "test_op_BIT_O::operator|(E, E)" | |
365 | "test_op_COMMA::operator,(E, E)" | |
366 | "test_op_DIV::operator/(E, E)" | |
367 | "test_op_DIV_A::operator/=(E, E)" | |
368 | "test_op_EQ::operator==(E, E)" | |
369 | "test_op_GT::operator>(E, E)" | |
370 | "test_op_GTE::operator>=(E, E)" | |
371 | "test_op_LAND::operator&&(E, E)" | |
372 | "test_op_LOR::operator||(E, E)" | |
373 | "test_op_LT::operator<(E, E)" | |
374 | "test_op_LTE::operator<=(E, E)" | |
375 | "test_op_MINUS::operator-(E, E)" | |
376 | "test_op_MINUS_A::operator-=(E, E)" | |
377 | "test_op_MOD::operator%(E, E)" | |
378 | "test_op_MOD_A::operator%=(E, E)" | |
379 | "test_op_MUL::operator*(E, E)" | |
380 | "test_op_MUL_A::operator*=(E, E)" | |
381 | "test_op_NEG::operator~(E)" | |
382 | "test_op_NEQ::operator!=(E, E)" | |
383 | "test_op_NOT::operator!(E)" | |
384 | "test_op_OE::operator|=(E, E)" | |
385 | "test_op_PLUS::operator+(E, E)" | |
386 | "test_op_PLUS_A::operator+=(E, E)" | |
387 | "test_op_POST_DEC::operator--(E, int)" | |
388 | "test_op_POST_INC::operator++(E, int)" | |
389 | "test_op_PRE_DEC::operator--(E)" | |
390 | "test_op_PRE_INC::operator++(E)" | |
391 | "test_op_SL::operator<<(E, E)" | |
392 | "test_op_SL_A::operator<<=(E, E)" | |
393 | "test_op_SR::operator>>(E, E)" | |
394 | "test_op_SR_A::operator>>=(E, E)" | |
395 | "test_op_XOR::operator^(E, E)" | |
396 | "test_op_XOR_A::operator^=(E, E)" | |
397 | } | |
398 | set linespecs_ws { | |
399 | "test_op_BIT_AND::operator & ( E , E )" | |
400 | "test_op_BIT_AND_A::operator &= ( E , E )" | |
401 | "test_op_BIT_O::operator | (E , E )" | |
402 | "test_op_COMMA::operator , ( E , E )" | |
403 | "test_op_DIV::operator / (E , E )" | |
404 | "test_op_DIV_A::operator /= ( E , E )" | |
405 | "test_op_EQ::operator == ( E , E )" | |
406 | "test_op_GT::operator > ( E , E )" | |
407 | "test_op_GTE::operator >= ( E , E )" | |
408 | "test_op_LAND::operator && ( E , E )" | |
409 | "test_op_LOR::operator || ( E , E )" | |
410 | "test_op_LT::operator < ( E , E )" | |
411 | "test_op_LTE::operator <= ( E , E )" | |
412 | "test_op_MINUS::operator - ( E , E )" | |
413 | "test_op_MINUS_A::operator -= ( E , E )" | |
414 | "test_op_MOD::operator % ( E , E )" | |
415 | "test_op_MOD_A::operator %= ( E , E )" | |
416 | "test_op_MUL::operator * ( E , E )" | |
417 | "test_op_MUL_A::operator *= ( E , E )" | |
418 | "test_op_NEG::operator ~ ( E )" | |
419 | "test_op_NEQ::operator != ( E , E )" | |
420 | "test_op_NOT::operator ! ( E )" | |
421 | "test_op_OE::operator |= ( E , E )" | |
422 | "test_op_PLUS::operator + ( E , E )" | |
423 | "test_op_PLUS_A::operator += ( E , E )" | |
424 | "test_op_POST_DEC::operator -- ( E , int )" | |
425 | "test_op_POST_INC::operator ++ ( E , int )" | |
426 | "test_op_PRE_DEC::operator -- ( E )" | |
427 | "test_op_PRE_INC::operator ++ ( E )" | |
428 | "test_op_SL::operator << ( E , E )" | |
429 | "test_op_SL_A::operator <<= ( E , E )" | |
430 | "test_op_SR::operator >> ( E , E )" | |
431 | "test_op_SR_A::operator >>= ( E , E )" | |
432 | "test_op_XOR::operator ^ ( E , E )" | |
433 | "test_op_XOR_A::operator ^= ( E , E )" | |
434 | } | |
435 | foreach linespec $locations linespec_ws $linespecs_ws { | |
436 | foreach cmd_prefix {"b" "b -function"} { | |
437 | with_test_prefix "no-whitespace" { | |
438 | set line "$cmd_prefix $linespec" | |
439 | set start [index_after "::operato" $line] | |
440 | test_complete_prefix_range $line $start | |
441 | } | |
442 | ||
443 | with_test_prefix "whitespace" { | |
444 | set line_ws "$cmd_prefix $linespec_ws" | |
445 | set start_ws [index_after "::operator " $line_ws] | |
446 | test_complete_prefix_range_re \ | |
447 | $line_ws "$cmd_prefix test_op_.*::operator .*\\\)" $start_ws | |
448 | } | |
449 | } | |
450 | ||
451 | check_explicit_skips_function_argument "$linespec" | |
452 | check_explicit_skips_function_argument "$linespec_ws" | |
453 | } | |
454 | } | |
455 | ||
456 | # Test completing an invalid (whitespace at the wrong place) operator | |
457 | # name. | |
458 | ||
459 | proc_with_prefix ops-invalid {} { | |
460 | foreach linespec { | |
461 | "test_op_BIT_AND_A::operator& =(E, E)" | |
462 | "test_op_DIV_A::operator/ =(E, E)" | |
463 | "test_op_EQ::operator= =(E, E)" | |
464 | "test_op_GTE::operator> =(E, E)" | |
465 | "test_op_LAND::operator& &(E, E)" | |
466 | "test_op_LOR::operator| |(E, E)" | |
467 | "test_op_LTE::operator< =(E, E)" | |
468 | "test_op_MINUS_A::operator- =(E, E)" | |
469 | "test_op_MOD_A::operator% =(E, E)" | |
470 | "test_op_MUL_A::operator* =(E, E)" | |
471 | "test_op_NEQ::operator! =(E, E)" | |
472 | "test_op_OE::operator| =(E, E)" | |
473 | "test_op_PLUS_A::operator+ =(E, E)" | |
474 | "test_op_POST_DEC::operator- -(E, int)" | |
475 | "test_op_POST_INC::operator+ +(E, int)" | |
476 | "test_op_PRE_DEC::operator- -(E)" | |
477 | "test_op_PRE_INC::operator+ +(E)" | |
478 | "test_op_SL::operator< <(E, E)" | |
479 | "test_op_SL_A::operator< < =(E, E)" | |
480 | "test_op_SR::operator> >(E, E)" | |
481 | "test_op_SR_A::operator> > =(E, E)" | |
482 | "test_op_XOR_A::operator^ =(E, E)" | |
483 | } { | |
484 | foreach cmd_prefix {"b" "b -function"} { | |
485 | test_gdb_complete_tab_none "$cmd_prefix $linespec" | |
486 | check_setting_bp_fails "$cmd_prefix $linespec" | |
487 | } | |
488 | } | |
489 | } | |
490 | ||
491 | # Test completing function/method FUNCTION. Completion is tested at | |
492 | # every point starting after START_AFTER. FUNCTION_WS is a version of | |
493 | # FUNCTION with extra (but valid) whitespace. FUNCTION_INVALID is a | |
494 | # version of FUNCTION with invalid whitespace. Tests that completion | |
495 | # of FUNCTION_WS completes to self, and that a completion of | |
496 | # FUNCTION_INVALID fails. | |
497 | ||
498 | proc test_function {function start_after function_ws {function_invalid ""}} { | |
499 | foreach cmd_prefix {"b" "b -function"} { | |
500 | set line "$cmd_prefix $function" | |
501 | set start [index_after $start_after $line] | |
502 | test_complete_prefix_range $line $start | |
503 | } | |
504 | ||
505 | check_explicit_skips_function_argument $function | |
506 | check_explicit_skips_function_argument $function_ws | |
507 | ||
508 | foreach cmd_prefix {"b" "b -function"} { | |
509 | test_gdb_complete_unique \ | |
510 | "$cmd_prefix $function_ws" \ | |
511 | "$cmd_prefix $function_ws" | |
512 | if {$function_invalid != ""} { | |
513 | test_gdb_complete_tab_none "$cmd_prefix $function_invalid" | |
514 | check_setting_bp_fails "$cmd_prefix $function_invalid" | |
515 | } | |
516 | } | |
517 | } | |
518 | ||
519 | # Test completing a user-defined conversion operator. | |
520 | ||
521 | proc_with_prefix conversion-operator {} { | |
522 | test_function \ | |
523 | "test_op_conversion::operator test_op_conversion_res const volatile**() const volatile" \ | |
524 | "test_op_conversio" \ | |
525 | "test_op_conversion::operator test_op_conversion_res const volatile * * ( ) const volatile"} | |
526 | ||
527 | # Test completing an assignment operator. | |
528 | ||
529 | proc_with_prefix assignment-operator {} { | |
530 | test_function \ | |
531 | "test_op_assign::operator=(test_op_assign const&)" \ | |
532 | "test_op_assig" \ | |
533 | "test_op_assign::operator = ( test_op_assign const & )" \ | |
534 | } | |
535 | ||
536 | # Test completing an arrow operator. | |
537 | ||
538 | proc_with_prefix arrow-operator {} { | |
539 | test_function \ | |
540 | "test_op_arrow::operator->()" \ | |
541 | "test_op_arro" \ | |
542 | "test_op_arrow::operator -> ( )" \ | |
543 | "test_op_arrow::operator - > ( )" | |
544 | } | |
545 | ||
546 | # The testcase driver. Calls all test procedures. | |
547 | ||
548 | proc test_driver {} { | |
549 | operator-delete | |
550 | operator-delete\[\] | |
551 | operator-new | |
552 | operator-new\[\] | |
553 | operator()-unique | |
554 | operator()-ambiguous | |
555 | operator\[\]-unique | |
556 | operator\[\]-ambiguous | |
557 | ops-valid-ambiguous | |
558 | ops-valid-unique | |
559 | ops-invalid | |
560 | conversion-operator | |
561 | assignment-operator | |
562 | arrow-operator | |
563 | } | |
564 | ||
565 | test_driver |