mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Use Test::Unit::TestCase instead of MiniTest::Unit::TestCase. Because
tests of fiddle already used customized assertions of ruby core. * test/fiddle/helper.rb: Use Test::Unit::TestCase for base class of testcase. * test/fiddle/test_*.rb: Use assert_raise instead of assert_raises. Remove needless includes for Test::Unit::Assertions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
52e8254b54
commit
24873d1a05
8 changed files with 9 additions and 15 deletions
|
@ -1,5 +1,5 @@
|
||||||
# frozen_string_literal: false
|
# frozen_string_literal: false
|
||||||
require 'minitest/autorun'
|
require 'test/unit'
|
||||||
require 'fiddle'
|
require 'fiddle'
|
||||||
|
|
||||||
# FIXME: this is stolen from DL and needs to be refactored.
|
# FIXME: this is stolen from DL and needs to be refactored.
|
||||||
|
@ -108,7 +108,7 @@ Fiddle::LIBC_SO = libc_so
|
||||||
Fiddle::LIBM_SO = libm_so
|
Fiddle::LIBM_SO = libm_so
|
||||||
|
|
||||||
module Fiddle
|
module Fiddle
|
||||||
class TestCase < MiniTest::Unit::TestCase
|
class TestCase < Test::Unit::TestCase
|
||||||
def setup
|
def setup
|
||||||
@libc = Fiddle.dlopen(LIBC_SO)
|
@libc = Fiddle.dlopen(LIBC_SO)
|
||||||
@libm = Fiddle.dlopen(LIBM_SO)
|
@libm = Fiddle.dlopen(LIBM_SO)
|
||||||
|
|
|
@ -7,15 +7,15 @@ end
|
||||||
module Fiddle
|
module Fiddle
|
||||||
class TestClosure < Fiddle::TestCase
|
class TestClosure < Fiddle::TestCase
|
||||||
def test_argument_errors
|
def test_argument_errors
|
||||||
assert_raises(TypeError) do
|
assert_raise(TypeError) do
|
||||||
Closure.new(TYPE_INT, TYPE_INT)
|
Closure.new(TYPE_INT, TYPE_INT)
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_raises(TypeError) do
|
assert_raise(TypeError) do
|
||||||
Closure.new('foo', [TYPE_INT])
|
Closure.new('foo', [TYPE_INT])
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_raises(TypeError) do
|
assert_raise(TypeError) do
|
||||||
Closure.new(TYPE_INT, ['meow!'])
|
Closure.new(TYPE_INT, ['meow!'])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -61,7 +61,7 @@ module Fiddle
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_undefined_ctype
|
def test_undefined_ctype
|
||||||
assert_raises(DLError) { parse_ctype('DWORD') }
|
assert_raise(DLError) { parse_ctype('DWORD') }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_undefined_ctype_with_type_alias
|
def test_undefined_ctype_with_type_alias
|
||||||
|
@ -93,7 +93,7 @@ module Fiddle
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_struct_undefined
|
def test_struct_undefined
|
||||||
assert_raises(DLError) { parse_struct_signature(['int i', 'DWORD cb']) }
|
assert_raise(DLError) { parse_struct_signature(['int i', 'DWORD cb']) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_struct_undefined_with_type_alias
|
def test_struct_undefined_with_type_alias
|
||||||
|
|
|
@ -13,7 +13,7 @@ module Fiddle
|
||||||
|
|
||||||
def test_syscall_with_tainted_string
|
def test_syscall_with_tainted_string
|
||||||
f = Function.new(@libc['system'], [TYPE_VOIDP], TYPE_INT)
|
f = Function.new(@libc['system'], [TYPE_VOIDP], TYPE_INT)
|
||||||
assert_raises(SecurityError) do
|
assert_raise(SecurityError) do
|
||||||
Thread.new {
|
Thread.new {
|
||||||
$SAFE = 1
|
$SAFE = 1
|
||||||
f.call("uname -rs".taint)
|
f.call("uname -rs".taint)
|
||||||
|
|
|
@ -6,8 +6,6 @@ end
|
||||||
|
|
||||||
module Fiddle
|
module Fiddle
|
||||||
class TestFunction < Fiddle::TestCase
|
class TestFunction < Fiddle::TestCase
|
||||||
include Test::Unit::Assertions
|
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
Fiddle.last_error = nil
|
Fiddle.last_error = nil
|
||||||
|
|
|
@ -8,8 +8,6 @@ module Fiddle
|
||||||
class TestHandle < TestCase
|
class TestHandle < TestCase
|
||||||
include Fiddle
|
include Fiddle
|
||||||
|
|
||||||
include Test::Unit::Assertions
|
|
||||||
|
|
||||||
def test_safe_handle_open
|
def test_safe_handle_open
|
||||||
t = Thread.new do
|
t = Thread.new do
|
||||||
$SAFE = 1
|
$SAFE = 1
|
||||||
|
|
|
@ -45,7 +45,7 @@ module Fiddle
|
||||||
|
|
||||||
class TestImport < TestCase
|
class TestImport < TestCase
|
||||||
def test_ensure_call_dlload
|
def test_ensure_call_dlload
|
||||||
err = assert_raises(RuntimeError) do
|
err = assert_raise(RuntimeError) do
|
||||||
Class.new do
|
Class.new do
|
||||||
extend Importer
|
extend Importer
|
||||||
extern "void *strcpy(char*, char*)"
|
extern "void *strcpy(char*, char*)"
|
||||||
|
|
|
@ -10,8 +10,6 @@ module Fiddle
|
||||||
Fiddle.dlwrap arg
|
Fiddle.dlwrap arg
|
||||||
end
|
end
|
||||||
|
|
||||||
include Test::Unit::Assertions
|
|
||||||
|
|
||||||
def test_cptr_to_int
|
def test_cptr_to_int
|
||||||
null = Fiddle::NULL
|
null = Fiddle::NULL
|
||||||
assert_equal(null.to_i, null.to_int)
|
assert_equal(null.to_i, null.to_int)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue