diff options
-rw-r--r-- | spec/ffi/function_spec.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/ffi/function_spec.rb b/spec/ffi/function_spec.rb index a1a50f3..7f90ea3 100644 --- a/spec/ffi/function_spec.rb +++ b/spec/ffi/function_spec.rb @@ -59,6 +59,16 @@ describe FFI::Function do expect(Foo.add(10, 10)).to eq(20) end + it 'can be attached to two modules' do + module Foo1; end + module Foo2; end + fp = FFI::Function.new(:int, [:int, :int], @libtest.find_function('testAdd')) + fp.attach(Foo1, 'add') + fp.attach(Foo2, 'add') + expect(Foo1.add(11, 11)).to eq(22) + expect(Foo2.add(12, 12)).to eq(24) + end + it 'can be used to extend an object' do fp = FFI::Function.new(:int, [:int, :int], @libtest.find_function('testAdd')) foo = Object.new |