File: function_type_spec.rb

package info (click to toggle)
ruby-ffi 1.17.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,000 kB
  • sloc: ruby: 9,539; ansic: 7,733; xml: 151; sh: 51; makefile: 14
file content (27 lines) | stat: -rw-r--r-- 924 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#
# This file is part of ruby-ffi.
# For licensing, see LICENSE.SPECS
#

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

describe "FFI::FunctionType", skip: RUBY_ENGINE != "ruby" do
  it 'is initialized with return type and a list of parameter types' do
    function_type = FFI::FunctionType.new(:int, [ :char, :ulong ])
    expect(function_type.return_type).to be == FFI::Type::Builtin::INT
    expect(function_type.param_types).to be == [ FFI::Type::Builtin::CHAR, FFI::Type::Builtin::ULONG ]
  end

  it 'has a memsize function' do
    base_size = ObjectSpace.memsize_of(Object.new)

    function_type = FFI::FunctionType.new(:int, [])
    size = ObjectSpace.memsize_of(function_type)
    expect(size).to be > base_size

    base_size = size
    function_type = FFI::FunctionType.new(:int, [:char])
    size = ObjectSpace.memsize_of(function_type)
    expect(size).to be > base_size
  end
end