3
3
require_relative "../support/protocol_test_case"
4
4
5
5
module DEBUGGER__
6
- class DAPVariablesTest < ProtocolTestCase
6
+ class DAPGlobalVariablesTest < ProtocolTestCase
7
7
PROGRAM = <<~RUBY
8
8
1| $a = 1
9
9
2| $b = 2
@@ -18,19 +18,19 @@ def test_eval_evaluates_global_variables
18
18
globals = gather_variables ( type : "globals" )
19
19
20
20
# User defined globals
21
- assert_includes ( globals , { name : "$a" , value : "1" , type : "Integer" } )
22
- assert_includes ( globals , { name : "$b" , value : "2" , type : "Integer" } )
21
+ assert_includes ( globals , { name : "$a" , value : "1" , type : "Integer" , variablesReference : 0 } )
22
+ assert_includes ( globals , { name : "$b" , value : "2" , type : "Integer" , variablesReference : 0 } )
23
23
24
24
# Ruby defined globals
25
- assert_includes ( globals , { name : "$VERBOSE" , value : "false" , type : "FalseClass" } )
26
- assert_includes ( globals , { name : "$stdout" , value : "#<IO:<STDOUT>>" , type : "IO" } )
25
+ assert_includes ( globals , { name : "$VERBOSE" , value : "false" , type : "FalseClass" , variablesReference : 0 } )
26
+ assert_includes ( globals , { name : "$stdout" , value : "#<IO:<STDOUT>>" , type : "IO" , variablesReference : 0 } )
27
27
28
28
req_terminate_debuggee
29
29
end
30
30
end
31
31
end
32
32
33
- class CDPVariablesTest < ProtocolTestCase
33
+ class CDPGlobalVariablesTest < ProtocolTestCase
34
34
PROGRAM = <<~RUBY
35
35
1| $a = 1
36
36
2| $b = 2
@@ -56,4 +56,30 @@ def test_eval_evaluates_global_variables
56
56
end
57
57
end
58
58
end
59
+
60
+ class DAPInstanceVariableTest < ProtocolTestCase
61
+ PROGRAM = <<~RUBY
62
+ 1| @a = 1
63
+ 2| @c = 3
64
+ 3| @b = 2
65
+ 4| __LINE__
66
+ RUBY
67
+
68
+ def test_ordering_instance_variables
69
+ run_protocol_scenario PROGRAM , cdp : false do
70
+ req_add_breakpoint 4
71
+ req_continue
72
+
73
+ locals = gather_variables
74
+
75
+ variables_reference = locals . find { |local | local [ :name ] == "%self" } [ :variablesReference ]
76
+ res = send_dap_request 'variables' , variablesReference : variables_reference
77
+
78
+ instance_vars = res . dig ( :body , :variables )
79
+ assert_equal instance_vars . map { |var | var [ :name ] } , [ "#class" , "@a" , "@b" , "@c" ]
80
+
81
+ req_terminate_debuggee
82
+ end
83
+ end
84
+ end
59
85
end
0 commit comments