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

* test/dl/test_callback.rb (**): using DL::Function to test callbacks

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tenderlove 2009-12-04 00:15:26 +00:00
parent 3e3f66e482
commit d5e1b514f9

View file

@ -34,20 +34,22 @@ module DL
called_with = dlunwrap(str)
end
func = CFunc.new(addr, TYPE_VOID, 'test')
f = Function.new(func, [TYPE_VOIDP])
func.call([dlwrap('foo')])
f.call(dlwrap('foo'))
assert_equal 'foo', called_with
end
def test_call_callback
called = false
addr = set_callback(TYPE_VOID, 0) do
addr = set_callback(TYPE_VOID, 1) do |foo|
called = true
end
func = CFunc.new(addr, TYPE_VOID, 'test')
func.call([])
f = Function.new(func, [TYPE_VOIDP])
f.call(nil)
assert called, 'function should be called'
end