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

Convert Symbol explicitly to a JS String and add test #117

Merged
merged 1 commit into from Jul 19, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/execjs/graaljs_runtime.rb
Expand Up @@ -98,10 +98,8 @@ def convert_ruby_to_js(value)
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
Expand Down
3 changes: 3 additions & 0 deletions test/test_execjs.rb
Expand Up @@ -172,6 +172,9 @@ def test_symbol
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
Expand Down