diff options
author | Lars Kanis <lars@greiz-reinsdorf.de> | 2023-04-21 08:34:07 +0200 |
---|---|---|
committer | Lars Kanis <lars@greiz-reinsdorf.de> | 2023-04-27 13:47:57 +0200 |
commit | e987ab50366a4b08617a20568eabdaa1fb761317 (patch) | |
tree | 0f10e6887c41ae27c0514ddd7c5b0d1b55a4f8ea /spec/ffi/library_spec.rb | |
parent | ad1a2e0cd5970e5d1618782a6ac2d5328811370d (diff) | |
download | ffi-e987ab50366a4b08617a20568eabdaa1fb761317.tar.gz |
Add the possibility to query attached funtions and variables
Diffstat (limited to 'spec/ffi/library_spec.rb')
-rw-r--r-- | spec/ffi/library_spec.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/ffi/library_spec.rb b/spec/ffi/library_spec.rb index f223d26..97790e5 100644 --- a/spec/ffi/library_spec.rb +++ b/spec/ffi/library_spec.rb @@ -193,6 +193,19 @@ describe "Library" do end expect(mod.bool_return_true).to be true end + + it "can reveal the function type" do + mod = Module.new do |m| + m.extend FFI::Library + ffi_lib File.expand_path(TestLibrary::PATH) + attach_function :bool_return_true, [ :string ], :bool + end + + fun = mod.attached_functions + expect(fun.keys).to eq(["bool_return_true"]) + expect(fun["bool_return_true"].param_types).to eq([FFI::Type::STRING]) + expect(fun["bool_return_true"].result_type).to eq(FFI::Type::BOOL) + end end def gvar_lib(name, type) @@ -320,6 +333,8 @@ describe "Library" do lib.gvar[:data] = i val = GlobalStruct.new(lib.get) expect(val[:data]).to eq(i) + + expect(lib.attached_variables).to eq({ gvar: GlobalStruct }) end end |