Convert Symbol explicitly to a JS String and add test

This commit is contained in:
Benoit Daloze 2022-07-19 17:17:52 +02:00
parent 82dbb78f71
commit 9e0855ddcd
2 changed files with 4 additions and 3 deletions

View File

@ -98,10 +98,8 @@ module ExecJS
case value
when nil, true, false, Integer, Float
value
when String
when String, Symbol
Truffle::Interop.as_truffle_string value
when Symbol
value.to_s
when Array
value.map { |e| convert_ruby_to_js(e) }
when Hash

View File

@ -172,6 +172,9 @@ class TestExecJS < Test
assert_equal "symbol", context.call("echo", :symbol)
assert_equal ["symbol"], context.call("echo", [:symbol])
assert_equal({"key" => "value"}, context.call("echo", {key: :value}))
context = ExecJS.compile("function myslice(str) { return str.slice(1); }")
assert_equal "ymbol", context.call("myslice", :symbol)
end
def test_additional_options