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

Fix sub \ escaping

This commit is contained in:
Joshua Peek 2011-03-10 17:19:18 -06:00
parent 998de3c0ff
commit bd4c71c224
2 changed files with 5 additions and 1 deletions

View file

@ -37,7 +37,9 @@ module ExecJS
def compile(source)
@runtime.send(:runner_source).dup.tap do |output|
output.sub!('#{source}', source)
output.sub!('#{source}') do
source
end
output.sub!('#{json2_source}') do
IO.read(ExecJS.root + "/support/json2.js")
end

View file

@ -14,6 +14,7 @@ module TestRuntime
assert_equal "hello", @runtime.exec("return 'hello'")
assert_equal({"a"=>1,"b"=>2}, @runtime.exec("return {a:1,b:2}"))
assert_equal "café", @runtime.exec("return 'café'")
assert_equal "\\", @runtime.exec('return "\\\\"')
end
def test_eval
@ -27,6 +28,7 @@ module TestRuntime
assert_equal "hello", @runtime.eval("'hello'")
assert_equal({"a"=>1,"b"=>2}, @runtime.eval("{a:1,b:2}"))
assert_equal "café", @runtime.eval("'café'")
assert_equal "\\", @runtime.eval('"\\\\"')
end
def test_compile