Skip to content

Commit a136d09

Browse files
committed
Add test for anonymous class instance
1 parent 670f96a commit a136d09

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
@@ -1033,14 +1033,14 @@ def variable_ name, obj, indexedVariables: 0, namedVariables: 0
10331033
if name
10341034
{ name: name,
10351035
value: str,
1036-
type: type_name,
1036+
type: type_name.to_s,
10371037
variablesReference: vid,
10381038
indexedVariables: indexedVariables,
10391039
namedVariables: namedVariables,
10401040
}
10411041
else
10421042
{ result: str,
1043-
type: type_name,
1043+
type: type_name.to_s,
10441044
variablesReference: vid,
10451045
indexedVariables: indexedVariables,
10461046
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_equal "", variable_info[:type]
153+
154+
req_terminate_debuggee
155+
end
156+
end
157+
end
136158
end

0 commit comments

Comments
 (0)