зеркало из https://github.com/github/ruby.git
Oops! Add another test and fix to_proc implementation
This commit is contained in:
Родитель
3d8e373a58
Коммит
d45466dc5b
|
@ -22,7 +22,8 @@ module Fiddle
|
|||
|
||||
# Turn this function in to a proc
|
||||
def to_proc
|
||||
lambda { |*args| self.call(*args) }
|
||||
this = self
|
||||
lambda { |*args| this.call(*args) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -115,6 +115,17 @@ module Fiddle
|
|||
assert_equal("123", str.to_s)
|
||||
end
|
||||
|
||||
def test_function_as_method
|
||||
f = Function.new(@libc['strcpy'], [TYPE_VOIDP, TYPE_VOIDP], TYPE_VOIDP)
|
||||
klass = Class.new do
|
||||
define_singleton_method(:strcpy, &f)
|
||||
end
|
||||
buff = +"000"
|
||||
str = klass.strcpy(buff, "123")
|
||||
assert_equal("123", buff)
|
||||
assert_equal("123", str.to_s)
|
||||
end
|
||||
|
||||
def test_nogvl_poll
|
||||
# XXX hack to quiet down CI errors on EINTR from r64353
|
||||
# [ruby-core:88360] [Misc #14937]
|
||||
|
|
Загрузка…
Ссылка в новой задаче