@@ -42,6 +42,17 @@ def verify_values(self, verify_dict, actual, varref_dict=None, expression=None):
42
42
('"%s" value "%s" doesn\' t start with' ' "%s")' )
43
43
% (key , actual_value , verify_value ),
44
44
)
45
+ if "notstartswith" in verify_dict :
46
+ verify = verify_dict ["notstartswith" ]
47
+ for key in verify :
48
+ verify_value = verify [key ]
49
+ actual_value = actual [key ]
50
+ startswith = actual_value .startswith (verify_value )
51
+ self .assertFalse (
52
+ startswith ,
53
+ ('"%s" value "%s" starts with' ' "%s")' )
54
+ % (key , actual_value , verify_value ),
55
+ )
45
56
if "contains" in verify_dict :
46
57
verify = verify_dict ["contains" ]
47
58
for key in verify :
@@ -155,6 +166,7 @@ def do_test_scopes_variables_setVariable_evaluate(
155
166
"argv" : {
156
167
"equals" : {"type" : "const char **" },
157
168
"startswith" : {"value" : "0x" },
169
+ "notstartswith" : {"value" : "0x0" },
158
170
"hasVariablesReference" : True ,
159
171
},
160
172
"pt" : {
@@ -166,8 +178,53 @@ def do_test_scopes_variables_setVariable_evaluate(
166
178
"buffer" : {"children" : buffer_children },
167
179
},
168
180
},
181
+ "pt_ptr" : {
182
+ "equals" : {"type" : "PointType *" },
183
+ "startswith" : {"value" : "0x" },
184
+ "notstartswith" : {"value" : "0x0" },
185
+ "hasVariablesReference" : True ,
186
+ },
187
+ "another_pt_ptr" : {
188
+ "equals" : {"type" : "PointType *" },
189
+ "startswith" : {"value" : "<null>" },
190
+ "hasVariablesReference" : True ,
191
+ },
169
192
"x" : {"equals" : {"type" : "int" }},
193
+ "some_int" : {
194
+ "equals" : {
195
+ "type" : "int" ,
196
+ "value" : "10" ,
197
+ },
198
+ },
199
+ "some_int_ptr" : {
200
+ "equals" : {"type" : "int *" },
201
+ "startswith" : {"value" : "0x" },
202
+ "notstartswith" : {"value" : "0x0" },
203
+ },
204
+ "another_int_ptr" : {
205
+ "equals" : {
206
+ "type" : "int *" ,
207
+ "value" : "<null>" ,
208
+ },
209
+ },
170
210
}
211
+ if enableAutoVariableSummaries :
212
+ verify_locals ["pt_ptr" ] = {
213
+ "equals" : {"type" : "PointType *" },
214
+ "hasVariablesReference" : True ,
215
+ "children" : {
216
+ "x" : {"equals" : {"type" : "int" , "value" : "11" }},
217
+ "y" : {"equals" : {"type" : "int" , "value" : "22" }},
218
+ "buffer" : {"children" : buffer_children },
219
+ },
220
+ }
221
+ verify_locals ["some_int_ptr" ] = {
222
+ "equals" : {
223
+ "type" : "int *" ,
224
+ "value" : "20" ,
225
+ },
226
+ }
227
+
171
228
verify_globals = {
172
229
"s_local" : {"equals" : {"type" : "float" , "value" : "2.25" }},
173
230
"::g_global" : {"equals" : {"type" : "int" , "value" : "123" }},
@@ -297,9 +354,9 @@ def do_test_scopes_variables_setVariable_evaluate(
297
354
298
355
verify_locals ["argc" ]["equals" ]["value" ] = "123"
299
356
verify_locals ["pt" ]["children" ]["x" ]["equals" ]["value" ] = "111"
300
- verify_locals ["x @ main.cpp:17 " ] = {"equals" : {"type" : "int" , "value" : "89" }}
301
- verify_locals ["x @ main.cpp:19 " ] = {"equals" : {"type" : "int" , "value" : "42" }}
302
- verify_locals ["x @ main.cpp:21 " ] = {"equals" : {"type" : "int" , "value" : "72" }}
357
+ verify_locals ["x @ main.cpp:23 " ] = {"equals" : {"type" : "int" , "value" : "89" }}
358
+ verify_locals ["x @ main.cpp:25 " ] = {"equals" : {"type" : "int" , "value" : "42" }}
359
+ verify_locals ["x @ main.cpp:27 " ] = {"equals" : {"type" : "int" , "value" : "72" }}
303
360
304
361
self .verify_variables (verify_locals , self .vscode .get_local_variables ())
305
362
@@ -310,29 +367,29 @@ def do_test_scopes_variables_setVariable_evaluate(
310
367
)
311
368
312
369
self .assertTrue (
313
- self .vscode .request_setVariable (1 , "x @ main.cpp:17 " , 17 )["success" ]
370
+ self .vscode .request_setVariable (1 , "x @ main.cpp:23 " , 17 )["success" ]
314
371
)
315
372
self .assertTrue (
316
- self .vscode .request_setVariable (1 , "x @ main.cpp:19 " , 19 )["success" ]
373
+ self .vscode .request_setVariable (1 , "x @ main.cpp:25 " , 19 )["success" ]
317
374
)
318
375
self .assertTrue (
319
- self .vscode .request_setVariable (1 , "x @ main.cpp:21 " , 21 )["success" ]
376
+ self .vscode .request_setVariable (1 , "x @ main.cpp:27 " , 21 )["success" ]
320
377
)
321
378
322
379
# The following should have no effect
323
380
self .assertFalse (
324
- self .vscode .request_setVariable (1 , "x @ main.cpp:21 " , "invalid" )["success" ]
381
+ self .vscode .request_setVariable (1 , "x @ main.cpp:27 " , "invalid" )["success" ]
325
382
)
326
383
327
- verify_locals ["x @ main.cpp:17 " ]["equals" ]["value" ] = "17"
328
- verify_locals ["x @ main.cpp:19 " ]["equals" ]["value" ] = "19"
329
- verify_locals ["x @ main.cpp:21 " ]["equals" ]["value" ] = "21"
384
+ verify_locals ["x @ main.cpp:23 " ]["equals" ]["value" ] = "17"
385
+ verify_locals ["x @ main.cpp:25 " ]["equals" ]["value" ] = "19"
386
+ verify_locals ["x @ main.cpp:27 " ]["equals" ]["value" ] = "21"
330
387
331
388
self .verify_variables (verify_locals , self .vscode .get_local_variables ())
332
389
333
390
# The plain x variable shold refer to the innermost x
334
391
self .assertTrue (self .vscode .request_setVariable (1 , "x" , 22 )["success" ])
335
- verify_locals ["x @ main.cpp:21 " ]["equals" ]["value" ] = "22"
392
+ verify_locals ["x @ main.cpp:27 " ]["equals" ]["value" ] = "22"
336
393
337
394
self .verify_variables (verify_locals , self .vscode .get_local_variables ())
338
395
@@ -349,9 +406,9 @@ def do_test_scopes_variables_setVariable_evaluate(
349
406
names = [var ["name" ] for var in locals ]
350
407
# The first shadowed x shouldn't have a suffix anymore
351
408
verify_locals ["x" ] = {"equals" : {"type" : "int" , "value" : "17" }}
352
- self .assertNotIn ("x @ main.cpp:17 " , names )
353
- self .assertNotIn ("x @ main.cpp:19 " , names )
354
- self .assertNotIn ("x @ main.cpp:21 " , names )
409
+ self .assertNotIn ("x @ main.cpp:23 " , names )
410
+ self .assertNotIn ("x @ main.cpp:25 " , names )
411
+ self .assertNotIn ("x @ main.cpp:27 " , names )
355
412
356
413
self .verify_variables (verify_locals , locals )
357
414
@@ -421,10 +478,32 @@ def do_test_scopes_and_evaluate_expansion(self, enableAutoVariableSummaries: boo
421
478
},
422
479
},
423
480
},
481
+ "pt_ptr" : {
482
+ "equals" : {"type" : "PointType *" },
483
+ "hasVariablesReference" : True ,
484
+ "missing" : ["indexedVariables" ],
485
+ },
486
+ "another_pt_ptr" : {
487
+ "equals" : {"type" : "PointType *" },
488
+ "hasVariablesReference" : True ,
489
+ "missing" : ["indexedVariables" ],
490
+ },
424
491
"x" : {
425
492
"equals" : {"type" : "int" },
426
493
"missing" : ["indexedVariables" ],
427
494
},
495
+ "some_int" : {
496
+ "equals" : {"type" : "int" },
497
+ "missing" : ["indexedVariables" ],
498
+ },
499
+ "some_int_ptr" : {
500
+ "equals" : {"type" : "int *" },
501
+ "missing" : ["indexedVariables" ],
502
+ },
503
+ "another_int_ptr" : {
504
+ "equals" : {"type" : "int *" },
505
+ "missing" : ["indexedVariables" ],
506
+ },
428
507
}
429
508
self .verify_variables (verify_locals , locals )
430
509
0 commit comments