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

Age of minitest

This commit is contained in:
Joshua Peek 2014-05-19 09:46:58 -04:00
parent d3398065d3
commit 79b239766a

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
require "test/unit" require "minitest/autorun"
require "execjs/module" require "execjs/module"
begin begin
@ -9,7 +9,13 @@ rescue ExecJS::RuntimeUnavailable => e
exit 2 exit 2
end 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 def test_runtime_available
runtime = ExecJS::ExternalRuntime.new(:command => "nonexistent") runtime = ExecJS::ExternalRuntime.new(:command => "nonexistent")
assert !runtime.available? assert !runtime.available?
@ -94,7 +100,7 @@ class TestExecJS < Test::Unit::TestCase
assert_equal "hello", result assert_equal "hello", result
assert_equal utf8, result.encoding assert_equal utf8, result.encoding
assert_raise Encoding::UndefinedConversionError do assert_raises Encoding::UndefinedConversionError do
binary = "\xde\xad\xbe\xef".force_encoding("BINARY") binary = "\xde\xad\xbe\xef".force_encoding("BINARY")
ExecJS.eval(binary) ExecJS.eval(binary)
end end
@ -113,7 +119,7 @@ class TestExecJS < Test::Unit::TestCase
assert_equal "¶hello", result assert_equal "¶hello", result
assert_equal utf8, result.encoding assert_equal utf8, result.encoding
assert_raise Encoding::UndefinedConversionError do assert_raises Encoding::UndefinedConversionError do
binary = "\xde\xad\xbe\xef".force_encoding("BINARY") binary = "\xde\xad\xbe\xef".force_encoding("BINARY")
context.eval(binary) context.eval(binary)
end end
@ -147,13 +153,13 @@ class TestExecJS < Test::Unit::TestCase
end end
def test_syntax_error def test_syntax_error
assert_raise ExecJS::RuntimeError do assert_raises ExecJS::RuntimeError do
ExecJS.exec(")") ExecJS.exec(")")
end end
end end
def test_thrown_exception def test_thrown_exception
assert_raise ExecJS::ProgramError do assert_raises ExecJS::ProgramError do
ExecJS.exec("throw 'hello'") ExecJS.exec("throw 'hello'")
end end
end end