mirror of
https://github.com/rails/execjs
synced 2023-03-27 23:21:20 -04:00
Add Spidermonkey runtime
This commit is contained in:
parent
954db082da
commit
c371fb474f
3 changed files with 30 additions and 0 deletions
|
@ -17,6 +17,10 @@ module ExecJS
|
||||||
:command => "node",
|
:command => "node",
|
||||||
:runner_path => runner_path("node.js")
|
:runner_path => runner_path("node.js")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Spidermonkey = Runtime.new(
|
||||||
|
:command => "js",
|
||||||
|
:runner_path => runner_path("spidermonkey.js")
|
||||||
)
|
)
|
||||||
|
|
||||||
V8 = Runtime.new(
|
V8 = Runtime.new(
|
||||||
|
|
18
lib/execjs/runtimes/spidermonkey.js
Normal file
18
lib/execjs/runtimes/spidermonkey.js
Normal 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]));
|
||||||
|
}
|
||||||
|
});
|
|
@ -55,6 +55,14 @@ class TestNodeRuntime < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class TestSpidermonkeyRuntime < Test::Unit::TestCase
|
||||||
|
include TestRuntime
|
||||||
|
|
||||||
|
def setup
|
||||||
|
@runtime = ExecJS::Runtimes::Spidermonkey
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class TestV8Runtime < Test::Unit::TestCase
|
class TestV8Runtime < Test::Unit::TestCase
|
||||||
include TestRuntime
|
include TestRuntime
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue