Skip to content

Commit

Permalink
Add test for anonymous class
Browse files Browse the repository at this point in the history
  • Loading branch information
adisonlampert committed Apr 5, 2023
1 parent 670f96a commit d59e3ca
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/debug/server_dap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1033,14 +1033,14 @@ def variable_ name, obj, indexedVariables: 0, namedVariables: 0
if name
{ name: name,
value: str,
type: type_name,
type: type_name.to_s,
variablesReference: vid,
indexedVariables: indexedVariables,
namedVariables: namedVariables,
}
else
{ result: str,
type: type_name,
type: type_name.to_s,
variablesReference: vid,
indexedVariables: indexedVariables,
namedVariables: namedVariables,
Expand Down
22 changes: 22 additions & 0 deletions test/protocol/variables_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,26 @@ def test_overwritten_class_method
end
end
end

class DAPAnonymousClass < ProtocolTestCase
PROGRAM = <<~RUBY
1| f = Class.new.new
2| __LINE__
RUBY

def test_anonymous_class
run_protocol_scenario PROGRAM, cdp: false do
req_add_breakpoint 2
req_continue

locals = gather_variables

variable_info = locals.find { |local| local[:name] == "f" }
assert_match /#<Class:.*>/, variable_info[:value]
assert_equal "", variable_info[:type]

req_terminate_debuggee
end
end
end
end

0 comments on commit d59e3ca

Please sign in to comment.