Skip to content

Commit

Permalink
Add spec for a function returning a function
Browse files Browse the repository at this point in the history
* Used by the sassc gem.
  • Loading branch information
eregon committed May 16, 2019
1 parent c394c48 commit a097226
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions spec/ffi/callback_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class S8F32S32 < FFI::Struct
attach_function :testCallbackVrS64, :testClosureVrLL, [ :cbVrS64 ], :long_long
attach_function :testCallbackVrU64, :testClosureVrLL, [ :cbVrU64 ], :ulong_long
attach_function :testCallbackVrP, :testClosureVrP, [ :cbVrP ], :pointer
attach_function :testCallbackReturningFunction, :testClosureVrP, [ :cbVrP ], :cbVrP
attach_function :testCallbackVrY, :testClosureVrP, [ :cbVrY ], S8F32S32.ptr
attach_function :testCallbackVrT, :testClosureVrT, [ :cbVrT ], S8F32S32.by_value
attach_function :testCallbackTrV, :testClosureTrV, [ :cbTrV, S8F32S32.ptr ], :void
Expand Down Expand Up @@ -266,6 +267,12 @@ class S8F32S32 < FFI::Struct
expect(LibTest.testCallbackVrP { p }).to eq(p)
end

it "returning a callback function" do
ret = LibTest.testCallbackReturningFunction { FFI::Pointer.new(42) }
expect(ret).to be_kind_of(FFI::Function)
expect(ret.address).to eq(42)
end

it "returning struct by value" do
skip "Segfault on 32 bit MINGW" if RUBY_PLATFORM == 'i386-mingw32'
s = LibTest::S8F32S32.new
Expand Down

0 comments on commit a097226

Please sign in to comment.