Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Commit

Permalink
Add JSC runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
sstephenson committed Feb 7, 2011
1 parent 9a5015e commit 378a923
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/execjs/runtimes.rb
@@ -1,5 +1,6 @@
module ExecJS module ExecJS
module Runtimes module Runtimes
autoload :JSC, "execjs/runtimes/jsc"
autoload :Node, "execjs/runtimes/node" autoload :Node, "execjs/runtimes/node"
autoload :V8, "execjs/runtimes/v8" autoload :V8, "execjs/runtimes/v8"


Expand Down
18 changes: 18 additions & 0 deletions lib/execjs/runtimes/jsc.js
@@ -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 changes: 13 additions & 0 deletions lib/execjs/runtimes/jsc.rb
@@ -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
8 changes: 8 additions & 0 deletions test/test_runtime.rb
Expand Up @@ -39,6 +39,14 @@ def test_thrown_exception
end end
end end


class TestJSCRuntime < Test::Unit::TestCase
include TestRuntime

def setup
@runtime = ExecJS::Runtimes::JSC.new
end
end

class TestNodeRuntime < Test::Unit::TestCase class TestNodeRuntime < Test::Unit::TestCase
include TestRuntime include TestRuntime


Expand Down

0 comments on commit 378a923

Please sign in to comment.