mirror of
https://github.com/rails/execjs
synced 2023-03-27 23:21:20 -04:00
Add JSC runtime
This commit is contained in:
parent
9a5015e612
commit
378a9236be
4 changed files with 40 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
module ExecJS
|
||||
module Runtimes
|
||||
autoload :JSC, "execjs/runtimes/jsc"
|
||||
autoload :Node, "execjs/runtimes/node"
|
||||
autoload :V8, "execjs/runtimes/v8"
|
||||
|
||||
|
|
18
lib/execjs/runtimes/jsc.js
Normal file
18
lib/execjs/runtimes/jsc.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]));
|
||||
}
|
||||
});
|
13
lib/execjs/runtimes/jsc.rb
Normal file
13
lib/execjs/runtimes/jsc.rb
Normal 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
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue