[DRE-commits] [ruby-execjs] 04/09: pulled tests from upstream

Caitlin Matos cm-guest at moszumanska.debian.org
Sat Jul 26 03:26:50 UTC 2014


This is an automated email from the git hooks/post-receive script.

cm-guest pushed a commit to branch master
in repository ruby-execjs.

commit 1b7fc320f5f72d2391026761e22f7877b4809d51
Author: Caitlin Matos <caitlin.matos at zoho.com>
Date:   Thu Jul 24 20:39:15 2014 -0400

    pulled tests from upstream
---
 debian/ruby-tests.rb | 81 +++++++++++++++++++++++++++++-----------------------
 1 file changed, 45 insertions(+), 36 deletions(-)

diff --git a/debian/ruby-tests.rb b/debian/ruby-tests.rb
index aef0cfa..e687937 100644
--- a/debian/ruby-tests.rb
+++ b/debian/ruby-tests.rb
@@ -1,6 +1,5 @@
-# encoding: UTF-8
-
-require "test/unit"
+# -*- coding: utf-8 -*-
+require "minitest/autorun"
 require "execjs/module"
 
 begin
@@ -10,22 +9,28 @@ rescue ExecJS::RuntimeUnavailable => e
   exit 2
 end
 
-class TestExecJS < Test::Unit::TestCase
+if defined? Minitest::Test
+  Test = Minitest::Test
+elsif defined? MiniTest::Unit::TestCase
+  Test = MiniTest::Unit::TestCase
+end
+
+class TestExecJS < Test
   def test_runtime_available
-    runtime = ExecJS::ExternalRuntime.new(:command => "nonexistent")
+    runtime = ExecJS::ExternalRuntime.new(command: "nonexistent")
     assert !runtime.available?
 
-    runtime = ExecJS::ExternalRuntime.new(:command => "ruby")
+    runtime = ExecJS::ExternalRuntime.new(command: "ruby")
     assert runtime.available?
   end
 
   def test_runtime_assignment
     original_runtime = ExecJS.runtime
-    runtime = ExecJS::ExternalRuntime.new(:command => "nonexistent")
+    runtime = ExecJS::ExternalRuntime.new(command: "nonexistent")
     assert_raises(ExecJS::RuntimeUnavailable) { ExecJS.runtime = runtime }
     assert_equal original_runtime, ExecJS.runtime
 
-    runtime = ExecJS::ExternalRuntime.new(:command => "ruby")
+    runtime = ExecJS::ExternalRuntime.new(command: "ruby")
     ExecJS.runtime = runtime
     assert_equal runtime, ExecJS.runtime
   ensure
@@ -84,41 +89,39 @@ class TestExecJS < Test::Unit::TestCase
     assert_equal "\\", ExecJS.eval('"\\\\"')
   end
 
-  if defined? Encoding
-    def test_encoding
-      utf8 = Encoding.find('UTF-8')
+  def test_encoding
+    utf8 = Encoding.find('UTF-8')
 
-      assert_equal utf8, ExecJS.exec("return 'hello'").encoding
-      assert_equal utf8, ExecJS.eval("'☃'").encoding
+    assert_equal utf8, ExecJS.exec("return 'hello'").encoding
+    assert_equal utf8, ExecJS.eval("'☃'").encoding
 
-      ascii = "'hello'".encode('US-ASCII')
-      result = ExecJS.eval(ascii)
-      assert_equal "hello", result
-      assert_equal utf8, result.encoding
+    ascii = "'hello'".encode('US-ASCII')
+    result = ExecJS.eval(ascii)
+    assert_equal "hello", result
+    assert_equal utf8, result.encoding
 
-      assert_raise Encoding::UndefinedConversionError do
-        binary = "\xde\xad\xbe\xef".force_encoding("BINARY")
-        ExecJS.eval(binary)
-      end
+    assert_raises Encoding::UndefinedConversionError do
+      binary = "\xde\xad\xbe\xef".force_encoding("BINARY")
+      ExecJS.eval(binary)
     end
+  end
 
-    def test_encoding_compile
-      utf8 = Encoding.find('UTF-8')
+  def test_encoding_compile
+    utf8 = Encoding.find('UTF-8')
 
-      context = ExecJS.compile("foo = function(v) { return '¶' + v; }".encode("ISO8859-15"))
+    context = ExecJS.compile("foo = function(v) { return '¶' + v; }".encode("ISO8859-15"))
 
-      assert_equal utf8, context.exec("return foo('hello')").encoding
-      assert_equal utf8, context.eval("foo('☃')").encoding
+    assert_equal utf8, context.exec("return foo('hello')").encoding
+    assert_equal utf8, context.eval("foo('☃')").encoding
 
-      ascii = "foo('hello')".encode('US-ASCII')
-      result = context.eval(ascii)
-      assert_equal "¶hello", result
-      assert_equal utf8, result.encoding
+    ascii = "foo('hello')".encode('US-ASCII')
+    result = context.eval(ascii)
+    assert_equal "¶hello", result
+    assert_equal utf8, result.encoding
 
-      assert_raise Encoding::UndefinedConversionError do
-        binary = "\xde\xad\xbe\xef".force_encoding("BINARY")
-        context.eval(binary)
-      end
+    assert_raises Encoding::UndefinedConversionError do
+      binary = "\xde\xad\xbe\xef".force_encoding("BINARY")
+      context.eval(binary)
     end
   end
 
@@ -150,15 +153,21 @@ class TestExecJS < Test::Unit::TestCase
   end
 
   def test_syntax_error
-    assert_raise ExecJS::RuntimeError do
+    assert_raises ExecJS::RuntimeError do
       ExecJS.exec(")")
     end
   end
 
   def test_thrown_exception
-    assert_raise ExecJS::ProgramError do
+    assert_raises ExecJS::ProgramError do
       ExecJS.exec("throw 'hello'")
     end
   end
 
+  def test_coffeescript
+    require "open-uri"
+    assert source = open("http://coffeescript.org/extras/coffee-script.js").read
+    context = ExecJS.compile(source)
+    assert_equal 64, context.call("CoffeeScript.eval", "((x) -> x * x)(8)")
+  end
 end

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-execjs.git



More information about the Pkg-ruby-extras-commits mailing list