@@ -39,7 +39,18 @@ def verify_values(self, verify_dict, actual, varref_dict=None, expression=None):
39
39
startswith = actual_value .startswith (verify_value )
40
40
self .assertTrue (
41
41
startswith ,
42
- ('"%s" value "%s" doesn\' t start with' ' "%s")' )
42
+ ('"%s" value "%s" doesn\' t start with "%s")' )
43
+ % (key , actual_value , verify_value ),
44
+ )
45
+ if "matches" in verify_dict :
46
+ verify = verify_dict ["matches" ]
47
+ for key in verify :
48
+ verify_value = verify [key ]
49
+ actual_value = actual [key ]
50
+ self .assertRegex (
51
+ actual_value ,
52
+ verify_value ,
53
+ ('"%s" value "%s" doesn\' t match pattern "%s")' )
43
54
% (key , actual_value , verify_value ),
44
55
)
45
56
if "contains" in verify_dict :
@@ -150,7 +161,7 @@ def do_test_scopes_variables_setVariable_evaluate(
150
161
self .continue_to_breakpoints (breakpoint_ids )
151
162
locals = self .dap_server .get_local_variables ()
152
163
globals = self .dap_server .get_global_variables ()
153
- buffer_children = make_buffer_verify_dict (0 , 32 )
164
+ buffer_children = make_buffer_verify_dict (0 , 16 )
154
165
verify_locals = {
155
166
"argc" : {
156
167
"equals" : {
@@ -243,18 +254,18 @@ def do_test_scopes_variables_setVariable_evaluate(
243
254
"pt" : {
244
255
"equals" : {"type" : "PointType" },
245
256
"startswith" : {
246
- "result" : "{x:11, y:22}"
257
+ "result" : "{x:11, y:22, buffer:{...} }"
247
258
if enableAutoVariableSummaries
248
259
else "PointType @ 0x"
249
260
},
250
261
"hasVariablesReference" : True ,
251
262
},
252
263
"pt.buffer" : {
253
- "equals" : {"type" : "int[32 ]" },
264
+ "equals" : {"type" : "int[16 ]" },
254
265
"startswith" : {
255
266
"result" : "{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...}"
256
267
if enableAutoVariableSummaries
257
- else "int[32 ] @ 0x"
268
+ else "int[16 ] @ 0x"
258
269
},
259
270
"hasVariablesReference" : True ,
260
271
},
@@ -440,7 +451,7 @@ def do_test_scopes_and_evaluate_expansion(self, enableAutoVariableSummaries: boo
440
451
},
441
452
"buffer" : {
442
453
"children" : buffer_children ,
443
- "equals" : {"indexedVariables" : 32 },
454
+ "equals" : {"indexedVariables" : 16 },
444
455
},
445
456
},
446
457
},
@@ -455,15 +466,85 @@ def do_test_scopes_and_evaluate_expansion(self, enableAutoVariableSummaries: boo
455
466
# the other temporary (from other UI).
456
467
expandable_expression = {
457
468
"name" : "pt" ,
458
- "response" : {
459
- "equals" : {"type" : "PointType" },
460
- "startswith" : {
461
- "result" : "{x:11, y:22}"
462
- if enableAutoVariableSummaries
463
- else "PointType @ 0x"
469
+ "context" : {
470
+ "repl" : {
471
+ "equals" : {"type" : "PointType" },
472
+ "equals" : {
473
+ "result" : """(PointType) $0 = {
474
+ x = 11
475
+ y = 22
476
+ buffer = {
477
+ [0] = 0
478
+ [1] = 1
479
+ [2] = 2
480
+ [3] = 3
481
+ [4] = 4
482
+ [5] = 5
483
+ [6] = 6
484
+ [7] = 7
485
+ [8] = 8
486
+ [9] = 9
487
+ [10] = 10
488
+ [11] = 11
489
+ [12] = 12
490
+ [13] = 13
491
+ [14] = 14
492
+ [15] = 15
493
+ }
494
+ }"""
495
+ },
496
+ "missing" : ["indexedVariables" ],
497
+ "hasVariablesReference" : True ,
498
+ },
499
+ "hover" : {
500
+ "equals" : {"type" : "PointType" },
501
+ "equals" : {
502
+ "result" : """(PointType) pt = {
503
+ x = 11
504
+ y = 22
505
+ buffer = {
506
+ [0] = 0
507
+ [1] = 1
508
+ [2] = 2
509
+ [3] = 3
510
+ [4] = 4
511
+ [5] = 5
512
+ [6] = 6
513
+ [7] = 7
514
+ [8] = 8
515
+ [9] = 9
516
+ [10] = 10
517
+ [11] = 11
518
+ [12] = 12
519
+ [13] = 13
520
+ [14] = 14
521
+ [15] = 15
522
+ }
523
+ }"""
524
+ },
525
+ "missing" : ["indexedVariables" ],
526
+ "hasVariablesReference" : True ,
527
+ },
528
+ "watch" : {
529
+ "equals" : {"type" : "PointType" },
530
+ "startswith" : {
531
+ "result" : "{x:11, y:22, buffer:{...}}"
532
+ if enableAutoVariableSummaries
533
+ else "PointType @ 0x"
534
+ },
535
+ "missing" : ["indexedVariables" ],
536
+ "hasVariablesReference" : True ,
537
+ },
538
+ "variables" : {
539
+ "equals" : {"type" : "PointType" },
540
+ "startswith" : {
541
+ "result" : "{x:11, y:22, buffer:{...}}"
542
+ if enableAutoVariableSummaries
543
+ else "PointType @ 0x"
544
+ },
545
+ "missing" : ["indexedVariables" ],
546
+ "hasVariablesReference" : True ,
464
547
},
465
- "missing" : ["indexedVariables" ],
466
- "hasVariablesReference" : True ,
467
548
},
468
549
"children" : {
469
550
"x" : {"equals" : {"type" : "int" , "value" : "11" }},
@@ -472,35 +553,29 @@ def do_test_scopes_and_evaluate_expansion(self, enableAutoVariableSummaries: boo
472
553
},
473
554
}
474
555
475
- # Evaluate from permanent UI.
476
- permanent_expr_varref_dict = {}
477
- response = self .dap_server .request_evaluate (
478
- expandable_expression ["name" ], frameIndex = 0 , threadId = None , context = "repl"
479
- )
480
- self .verify_values (
481
- expandable_expression ["response" ],
482
- response ["body" ],
483
- permanent_expr_varref_dict ,
484
- expandable_expression ["name" ],
485
- )
486
-
487
- # Evaluate from temporary UI.
488
- temporary_expr_varref_dict = {}
489
- response = self .dap_server .request_evaluate (expandable_expression ["name" ])
490
- self .verify_values (
491
- expandable_expression ["response" ],
492
- response ["body" ],
493
- temporary_expr_varref_dict ,
494
- expandable_expression ["name" ],
495
- )
556
+ # Evaluate from known contexts.
557
+ expr_varref_dict = {}
558
+ for context , verify_dict in expandable_expression ["context" ].items ():
559
+ response = self .dap_server .request_evaluate (
560
+ expandable_expression ["name" ],
561
+ frameIndex = 0 ,
562
+ threadId = None ,
563
+ context = context ,
564
+ )
565
+ self .verify_values (
566
+ verify_dict ,
567
+ response ["body" ],
568
+ expr_varref_dict ,
569
+ expandable_expression ["name" ],
570
+ )
496
571
497
572
# Evaluate locals again.
498
573
locals = self .dap_server .get_local_variables ()
499
574
self .verify_variables (verify_locals , locals )
500
575
501
576
# Verify the evaluated expressions before second locals evaluation
502
577
# can be expanded.
503
- var_ref = temporary_expr_varref_dict [expandable_expression ["name" ]]
578
+ var_ref = expr_varref_dict [expandable_expression ["name" ]]
504
579
response = self .dap_server .request_variables (var_ref )
505
580
self .verify_variables (
506
581
expandable_expression ["children" ], response ["body" ]["variables" ]
@@ -516,7 +591,7 @@ def do_test_scopes_and_evaluate_expansion(self, enableAutoVariableSummaries: boo
516
591
)
517
592
self .continue_to_breakpoints (breakpoint_ids )
518
593
519
- var_ref = permanent_expr_varref_dict [expandable_expression ["name" ]]
594
+ var_ref = expr_varref_dict [expandable_expression ["name" ]]
520
595
response = self .dap_server .request_variables (var_ref )
521
596
self .verify_variables (
522
597
expandable_expression ["children" ], response ["body" ]["variables" ]
0 commit comments