Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Improve existing tests
  • Loading branch information
amomchilov authored and st0012 committed Dec 18, 2024
commit 75da7ca6c3fdf9d89113cfeef81b169e967297f3
1 change: 1 addition & 0 deletions lib/debug/server_dap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,7 @@ def process_dap args
case req.dig('arguments', 'filter')
when 'indexed'
start = req.dig('arguments', 'start') || 0
# FIXME: `req.dig('arguments', 'count')` needs to be capped to be `<= obj.size`.
count = req.dig('arguments', 'count') || obj.size
vars = (start ... (start + count)).map{|i|
variable(i.to_s, obj[i])
Expand Down
41 changes: 21 additions & 20 deletions test/protocol/hover_raw_dap_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -578,80 +578,81 @@ def test_hover_works_correctly
variables: [
{
name: "0",
value: /.*/,
type: /.*/,
value: "JSON::Ext::Generator::GeneratorMethods::Integer",
type: "Module",
variablesReference: 22,
indexedVariables: 0,
namedVariables: /\d+/
},
{
name: "1",
value: /.*/,
type: /.*/,
value: "Numeric",
type: "Class",
variablesReference: 23,
indexedVariables: 0,
namedVariables: /\d+/
},
{
name: "2",
value: /.*/,
type: /.*/,
value: "Comparable",
type: "Module",
variablesReference: 24,
indexedVariables: 0,
namedVariables: /\d+/
},
{
name: "3",
value: /.*/,
type: /.*/,
value: "Object",
type: "Class",
variablesReference: 25,
indexedVariables: 0,
namedVariables: /\d+/
},
{
name: "4",
value: /.*/,
type: /.*/,
value: "JSON::Ext::Generator::GeneratorMethods::Object",
type: "Module",
variablesReference: 26,
indexedVariables: 0,
namedVariables: /\d+/
},
{
name: "5",
value: /.*/,
type: /.*/,
value: "PP::ObjectMixin",
type: "Module",
variablesReference: 27,
indexedVariables: 0,
namedVariables: /\d+/
},
{
name: "6",
value: /.*/,
type: /.*/,
value: "DEBUGGER__::TrapInterceptor",
type: "Module",
variablesReference: 28,
indexedVariables: 0,
namedVariables: /\d+/
},
{
name: "7",
value: /.*/,
type: /.*/,
value: "Kernel",
type: "Module",
variablesReference: 29,
indexedVariables: 0,
namedVariables: /\d+/
},
{
name: "8",
value: /.*/,
type: /.*/,
value: "BasicObject",
type: "Class",
variablesReference: 30,
indexedVariables: 0,
namedVariables: /\d+/
},
{
# This is an extra entry caused by an out-of-bounds index access in server_dap.rb
name: "9",
value: /.*/,
type: /.*/,
value: nil,
type: NilClass,
variablesReference: 31,
indexedVariables: 0,
namedVariables: /\d+/
Expand Down
2 changes: 1 addition & 1 deletion test/protocol/variables_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_ordering_instance_variables
res = send_dap_request 'variables', variablesReference: variables_reference

instance_vars = res.dig(:body, :variables)
assert_equal instance_vars.map { |var| var[:name] }, ["#class", "@a", "@b", "@c"]
assert_equal ["#class", "@a", "@b", "@c"], instance_vars.map { |var| var[:name] }

req_terminate_debuggee
end
Expand Down