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:
parent
3e3f66e482
commit
d5e1b514f9
1 changed files with 5 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue