Skip to content

Commit 7b1ef07

Browse files
adisonlampertko1
authored andcommitted
Add test for anonymous class instance
1 parent a767100 commit 7b1ef07

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

lib/debug/server_dap.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1047,14 +1047,14 @@ def variable_ name, obj, indexedVariables: 0, namedVariables: 0
10471047
if name
10481048
{ name: name,
10491049
value: str,
1050-
type: type_name,
1050+
type: type_name || klass.to_s,
10511051
variablesReference: vid,
10521052
indexedVariables: indexedVariables,
10531053
namedVariables: namedVariables,
10541054
}
10551055
else
10561056
{ result: str,
1057-
type: type_name,
1057+
type: type_name || klass.to_s,
10581058
variablesReference: vid,
10591059
indexedVariables: indexedVariables,
10601060
namedVariables: namedVariables,

test/protocol/variables_test.rb

+22
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,26 @@ def test_overwritten_class_method
133133
end
134134
end
135135
end
136+
137+
class DAPAnonymousClassInstance < ProtocolTestCase
138+
PROGRAM = <<~RUBY
139+
1| f = Class.new.new
140+
2| __LINE__
141+
RUBY
142+
143+
def test_anonymous_class_instance
144+
run_protocol_scenario PROGRAM, cdp: false do
145+
req_add_breakpoint 2
146+
req_continue
147+
148+
locals = gather_variables
149+
150+
variable_info = locals.find { |local| local[:name] == "f" }
151+
assert_match /#<Class:.*>/, variable_info[:value]
152+
assert_match /#<Class:.*>/, variable_info[:type]
153+
154+
req_terminate_debuggee
155+
end
156+
end
157+
end
136158
end

0 commit comments

Comments
 (0)