From 9e0855ddcdfc573b6271fb96e865d76e3433745f Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Tue, 19 Jul 2022 17:17:52 +0200 Subject: [PATCH] Convert Symbol explicitly to a JS String and add test --- lib/execjs/graaljs_runtime.rb | 4 +--- test/test_execjs.rb | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/execjs/graaljs_runtime.rb b/lib/execjs/graaljs_runtime.rb index fe2b5db..86121b0 100644 --- a/lib/execjs/graaljs_runtime.rb +++ b/lib/execjs/graaljs_runtime.rb @@ -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 diff --git a/test/test_execjs.rb b/test/test_execjs.rb index dbf9703..f5b25b5 100644 --- a/test/test_execjs.rb +++ b/test/test_execjs.rb @@ -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