Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve assert_repl_result for CDP #951

Merged
merged 1 commit into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion test/protocol/eval_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ class EvalTest < ProtocolTestCase
6| f = 6
RUBY

def test_eval_evaluates_arithmetic_expressions
def test_eval_evaluates_expressions
run_protocol_scenario PROGRAM do
req_add_breakpoint 5
req_continue
assert_repl_result({value: '2', type: 'Integer'}, 'a')
assert_repl_result({value: '4', type: 'Integer'}, 'd')
assert_repl_result({value: '3', type: 'Integer'}, '1+2')
assert_repl_result({value: 'false', type: 'FalseClass'}, 'a == 1')
req_terminate_debuggee
end
end
Expand Down
10 changes: 5 additions & 5 deletions test/support/protocol_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,10 @@ def close_reader
HOST = '127.0.0.1'

JAVASCRIPT_TYPE_TO_CLASS_MAPS = {
'string' => String,
'number' => Integer,
'boolean' => [TrueClass, FalseClass],
'symbol' => Symbol
'string' => "String",
'number' => "Integer",
'boolean' => ["TrueClass", "FalseClass"],
'symbol' => "Symbol"
}

def assert_eval_result context, expression, expected, frame_idx
Expand Down Expand Up @@ -497,7 +497,7 @@ def assert_eval_result context, expression, expected, frame_idx

failure_msg = FailureMessage.new{create_protocol_message "result:\n#{JSON.pretty_generate res}"}

cl = res.dig(:result, :result, :className) || JAVASCRIPT_TYPE_TO_CLASS_MAPS[res.dig(:result, :result, :type)].inspect
cl = res.dig(:result, :result, :className) || JAVASCRIPT_TYPE_TO_CLASS_MAPS[res.dig(:result, :result, :type)]
result_type = Array cl
assert_include result_type, expected[:type], failure_msg

Expand Down