mirror of
https://github.com/rails/execjs
synced 2023-03-27 23:21:20 -04:00
Convert Symbol explicitly to a JS String and add test
This commit is contained in:
parent
82dbb78f71
commit
9e0855ddcd
2 changed files with 4 additions and 3 deletions
|
@ -98,10 +98,8 @@ module ExecJS
|
||||||
case value
|
case value
|
||||||
when nil, true, false, Integer, Float
|
when nil, true, false, Integer, Float
|
||||||
value
|
value
|
||||||
when String
|
when String, Symbol
|
||||||
Truffle::Interop.as_truffle_string value
|
Truffle::Interop.as_truffle_string value
|
||||||
when Symbol
|
|
||||||
value.to_s
|
|
||||||
when Array
|
when Array
|
||||||
value.map { |e| convert_ruby_to_js(e) }
|
value.map { |e| convert_ruby_to_js(e) }
|
||||||
when Hash
|
when Hash
|
||||||
|
|
|
@ -172,6 +172,9 @@ class TestExecJS < Test
|
||||||
assert_equal "symbol", context.call("echo", :symbol)
|
assert_equal "symbol", context.call("echo", :symbol)
|
||||||
assert_equal ["symbol"], context.call("echo", [:symbol])
|
assert_equal ["symbol"], context.call("echo", [:symbol])
|
||||||
assert_equal({"key" => "value"}, context.call("echo", {key: :value}))
|
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
|
end
|
||||||
|
|
||||||
def test_additional_options
|
def test_additional_options
|
||||||
|
|
Loading…
Reference in a new issue