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

Add JSC runtime

This commit is contained in:
Sam Stephenson 2011-02-06 19:44:32 -06:00
parent 9a5015e612
commit 378a9236be
4 changed files with 40 additions and 0 deletions

View file

@ -1,5 +1,6 @@
module ExecJS
module Runtimes
autoload :JSC, "execjs/runtimes/jsc"
autoload :Node, "execjs/runtimes/node"
autoload :V8, "execjs/runtimes/v8"

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

@ -0,0 +1,13 @@
module ExecJS
module Runtimes
class JSC < Runtime
def command(filename)
"/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc #{filename}"
end
def runner_path
File.expand_path('../v8.js', __FILE__)
end
end
end
end

View file

@ -39,6 +39,14 @@ module TestRuntime
end
end
class TestJSCRuntime < Test::Unit::TestCase
include TestRuntime
def setup
@runtime = ExecJS::Runtimes::JSC.new
end
end
class TestNodeRuntime < Test::Unit::TestCase
include TestRuntime