From 3f79722a0c0b1cbed973a3edc963a44e3865f1a1 Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Sun, 16 Apr 2023 21:21:06 +0200 Subject: Add a spec that adds one Function to several modules It was not yet tested. --- spec/ffi/function_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 -- cgit v1.2.1