Sha256: b801bc20853ebf1ebc0150befaef4775c5f177bc60bb57ef7c8756f3278e492a

Contents?: true

Size: 869 Bytes

Versions: 3

Compression:

Stored size: 869 Bytes

Contents

#
# This file is part of ruby-ffi.
# For licensing, see LICENSE.SPECS
#

require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
require 'ffi'

describe "async callback" do
  module LibTest
    extend FFI::Library
    ffi_lib TestLibrary::PATH
    AsyncIntCallback = callback [ :int ], :void

    @blocking = true
    attach_function :testAsyncCallback, [ AsyncIntCallback, :int ], :void
  end

  it ":int (0x7fffffff) argument" do
    v = 0xdeadbeef
    called = false
    cb = Proc.new {|i| v = i; called = true }
    LibTest.testAsyncCallback(cb, 0x7fffffff) 
    called.should be_true
    v.should == 0x7fffffff
  end
  
  it "called a second time" do
    v = 0xdeadbeef
    called = false
    cb = Proc.new {|i| v = i; called = true }
    LibTest.testAsyncCallback(cb, 0x7fffffff) 
    called.should be_true
    v.should == 0x7fffffff
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ffi-1.9.5-x64-mingw32 spec/ffi/async_callback_spec.rb
ffi-1.9.5-x86-mingw32 spec/ffi/async_callback_spec.rb
ffi-1.9.5 spec/ffi/async_callback_spec.rb