1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Oops! Add another test and fix to_proc implementation

This commit is contained in:
Aaron Patterson 2021-02-26 10:06:30 -08:00
parent 3d8e373a58
commit d45466dc5b
No known key found for this signature in database
GPG key ID: 953170BCB4FFAFC6
2 changed files with 13 additions and 1 deletions

View file

@ -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

View file

@ -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]