Permalink
Browse files

Add Spidermonkey runtime

  • Loading branch information...
1 parent 954db08 commit c371fb474f2e12298dd4a3a049536845b947c14d @sstephenson committed Feb 7, 2011
Showing with 30 additions and 0 deletions.
  1. +4 −0 lib/execjs/runtimes.rb
  2. +18 −0 lib/execjs/runtimes/spidermonkey.js
  3. +8 −0 test/test_runtimes.rb
View
@@ -17,6 +17,10 @@ def self.runner_path(path)
:command => "node",
:runner_path => runner_path("node.js")
)
+
+ Spidermonkey = Runtime.new(
+ :command => "js",
+ :runner_path => runner_path("spidermonkey.js")
)
V8 = Runtime.new(
@@ -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
@@ -55,6 +55,14 @@ def setup
end
end
+class TestSpidermonkeyRuntime < Test::Unit::TestCase
+ include TestRuntime
+
+ def setup
+ @runtime = ExecJS::Runtimes::Spidermonkey
+ end
+end
+
class TestV8Runtime < Test::Unit::TestCase
include TestRuntime

0 comments on commit c371fb4

Please sign in to comment.