1
0
Fork 0
mirror of https://github.com/rails/execjs synced 2023-03-27 23:21:20 -04:00

Merge pull request #117 from eregon/fix-symbol-conversion

Convert Symbol explicitly to a JS String and add test
This commit is contained in:
Jean Boussier 2022-07-20 01:26:14 +02:00 committed by GitHub
commit e553b3f8a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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