diff options
Diffstat (limited to 'spec/ffi')
-rw-r--r-- | spec/ffi/library_spec.rb | 18 | ||||
-rw-r--r-- | spec/ffi/struct_by_ref_spec.rb | 1 | ||||
-rw-r--r-- | spec/ffi/variadic_spec.rb | 2 |
3 files changed, 18 insertions, 3 deletions
diff --git a/spec/ffi/library_spec.rb b/spec/ffi/library_spec.rb index 97790e5..c9542b9 100644 --- a/spec/ffi/library_spec.rb +++ b/spec/ffi/library_spec.rb @@ -333,9 +333,25 @@ describe "Library" do lib.gvar[:data] = i val = GlobalStruct.new(lib.get) expect(val[:data]).to eq(i) + end + end - expect(lib.attached_variables).to eq({ gvar: GlobalStruct }) + it "can reveal its attached global struct based variables" do + lib = Module.new do |m| + m.extend FFI::Library + ffi_lib TestLibrary::PATH + attach_variable :gvari, "gvar_gstruct", GlobalStruct + end + expect(lib.attached_variables).to eq({ "gvari" => GlobalStruct }) + end + + it "can reveal its attached global variables" do + lib = Module.new do |m| + m.extend FFI::Library + ffi_lib TestLibrary::PATH + attach_variable :gvaro, "gvar_u32", :uint32 end + expect(lib.attached_variables).to eq({ "gvaro" => FFI::Type::UINT32 }) end it "should have shareable constants for Ractor", :ractor do diff --git a/spec/ffi/struct_by_ref_spec.rb b/spec/ffi/struct_by_ref_spec.rb index 0f48fbb..0c01137 100644 --- a/spec/ffi/struct_by_ref_spec.rb +++ b/spec/ffi/struct_by_ref_spec.rb @@ -42,6 +42,7 @@ describe FFI::Struct, ' by_ref' do it "can reveal the mapped type converter" do param_type = @api.attached_functions["struct_test"].param_types[0] + expect(param_type).to be_a(FFI::Type::Mapped) expect(param_type.converter).to be_a(FFI::StructByReference) end end diff --git a/spec/ffi/variadic_spec.rb b/spec/ffi/variadic_spec.rb index fdaf31c..283878b 100644 --- a/spec/ffi/variadic_spec.rb +++ b/spec/ffi/variadic_spec.rb @@ -23,8 +23,6 @@ describe "Function with variadic arguments" do attach_function :testBlockingClose, [ :pointer ], :void attach_function :testCallbackVrDva, :testClosureVrDva, [ :double, :varargs ], :double attach_function :testCallbackVrILva, :testClosureVrILva, [ :int, :long, :varargs ], :long - - freeze end it "takes enum arguments" do |