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

Add Spidermonkey runtime

This commit is contained in:
Sam Stephenson 2011-02-06 20:13:24 -06:00
parent 954db082da
commit c371fb474f
3 changed files with 30 additions and 0 deletions

View file

@ -17,6 +17,10 @@ module ExecJS
:command => "node",
:runner_path => runner_path("node.js")
)
Spidermonkey = Runtime.new(
:command => "js",
:runner_path => runner_path("spidermonkey.js")
)
V8 = Runtime.new(

View file

@ -0,0 +1,18 @@
(function(program, execJS) { execJS(program) })(function() { #{source}
}, function(program) {
var output;
try {
result = program();
if (typeof result == 'undefined' && result !== null) {
print('["ok"]');
} else {
try {
print(JSON.stringify(['ok', result]));
} catch (err) {
print('["err"]');
}
}
} catch (err) {
print(JSON.stringify(['err', '' + err]));
}
});

View file

@ -55,6 +55,14 @@ class TestNodeRuntime < Test::Unit::TestCase
end
end
class TestSpidermonkeyRuntime < Test::Unit::TestCase
include TestRuntime
def setup
@runtime = ExecJS::Runtimes::Spidermonkey
end
end
class TestV8Runtime < Test::Unit::TestCase
include TestRuntime