diff options
author | Lars Kanis <lars@greiz-reinsdorf.de> | 2022-04-21 10:08:31 +0200 |
---|---|---|
committer | Lars Kanis <lars@greiz-reinsdorf.de> | 2022-04-21 10:08:31 +0200 |
commit | 29537f1468b768aac69903edeb4b1d31c6621bf5 (patch) | |
tree | ff111c4ff109f4d0581117ef604dd12c33e037a3 | |
parent | 9243288401ca7ce4e1178f2478d7fdb1699923eb (diff) | |
download | ffi-29537f1468b768aac69903edeb4b1d31c6621bf5.tar.gz |
Fix wrong usage of ManagedStruct.release in specs
This stand out since ruby-3.1 prints a backtrace of errors happening in GC calls:
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:93: warning: Exception in finalizer #<FFI::AutoPointer::CallableReleaser:0x000002398b437f30 @ptr=#<FFI::Pointer address=0x0000000000001234>, @proc=#<Method: ManagedStructWithInitialize.release() C:/projects/ffi-aofqa/spec/ffi/struct_initialize_spec.rb:31>, @autorelease=true>
C:/projects/ffi-aofqa/spec/ffi/struct_initialize_spec.rb:31:in `release': wrong number of arguments (given 1, expected 0) (ArgumentError)
from C:/projects/ffi-aofqa/lib/ffi/autopointer.rb:175:in `call'
from C:/projects/ffi-aofqa/lib/ffi/autopointer.rb:175:in `release'
from C:/projects/ffi-aofqa/lib/ffi/autopointer.rb:150:in `call'
-rw-r--r-- | spec/ffi/managed_struct_spec.rb | 4 | ||||
-rw-r--r-- | spec/ffi/struct_initialize_spec.rb | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/spec/ffi/managed_struct_spec.rb b/spec/ffi/managed_struct_spec.rb index 9b02c34..2520d9b 100644 --- a/spec/ffi/managed_struct_spec.rb +++ b/spec/ffi/managed_struct_spec.rb @@ -21,7 +21,7 @@ describe "Managed Struct" do it "should be the right class" do class WhatClassAmI < FFI::ManagedStruct layout :i, :int - def self.release + def self.release(_ptr) end end @@ -31,7 +31,7 @@ describe "Managed Struct" do it "should build with self reference" do class ClassWithSelfRef < FFI::ManagedStruct layout :data, self.ptr - def self.release + def self.release(_ptr) end end diff --git a/spec/ffi/struct_initialize_spec.rb b/spec/ffi/struct_initialize_spec.rb index beb2477..a53ab8e 100644 --- a/spec/ffi/struct_initialize_spec.rb +++ b/spec/ffi/struct_initialize_spec.rb @@ -28,7 +28,7 @@ describe FFI::ManagedStruct, ' with an initialize function' do super FFI::MemoryPointer.new(:pointer).put_int(0, 0x1234).get_pointer(0) self.magic = 42 end - def self.release;end + def self.release(_ptr);end end expect(ManagedStructWithInitialize.new.magic).to eq(42) end |