Skip to content

Commit e711a0c

Browse files
committed
Add spec for a function returning a function
* Used by the sassc gem.
1 parent d7bc082 commit e711a0c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

spec/ffi/callback_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class S8F32S32 < FFI::Struct
7575
attach_function :testCallbackVrS64, :testClosureVrLL, [ :cbVrS64 ], :long_long
7676
attach_function :testCallbackVrU64, :testClosureVrLL, [ :cbVrU64 ], :ulong_long
7777
attach_function :testCallbackVrP, :testClosureVrP, [ :cbVrP ], :pointer
78+
attach_function :testCallbackReturningFunction, :testClosureVrP, [ :cbVrP ], :cbVrP
7879
attach_function :testCallbackVrY, :testClosureVrP, [ :cbVrY ], S8F32S32.ptr
7980
# struct by value
8081
# attach_function :testCallbackVrT, :testClosureVrT, [ :cbVrT ], S8F32S32.by_value
@@ -267,6 +268,12 @@ class S8F32S32 < FFI::Struct
267268
expect(LibTest.testCallbackVrP { p }).to eq(p)
268269
end
269270

271+
it "returning a callback function" do
272+
ret = LibTest.testCallbackReturningFunction { FFI::Pointer.new(42) }
273+
expect(ret).to be_kind_of(FFI::Function)
274+
expect(ret.address).to eq(42)
275+
end
276+
270277
it "returning struct by value" do
271278
next # struct by value
272279
skip "Segfault on 32 bit MINGW" if RUBY_PLATFORM == 'i386-mingw32'

0 commit comments

Comments
 (0)