summaryrefslogtreecommitdiff
path: root/spec/ffi/type_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ffi/type_spec.rb')
-rw-r--r--spec/ffi/type_spec.rb35
1 files changed, 34 insertions, 1 deletions
diff --git a/spec/ffi/type_spec.rb b/spec/ffi/type_spec.rb
index eb48a43..e880c83 100644
--- a/spec/ffi/type_spec.rb
+++ b/spec/ffi/type_spec.rb
@@ -5,7 +5,7 @@
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
-describe "FFI::Type" do
+describe FFI::Type do
it 'has a memsize function', skip: RUBY_ENGINE != "ruby" do
base_size = ObjectSpace.memsize_of(Object.new)
@@ -40,4 +40,37 @@ describe "FFI::Type" do
size = ObjectSpace.memsize_of(FFI::Type::Builtin::CHAR)
expect(size).to be > base_size
end
+
+ it "should be shareable with Ractor", :ractor do
+ expect(Ractor.shareable?(FFI::Type.new(5))).to eq(true)
+ end
+
+ describe :Builtin do
+ it "should be shareable with Ractor", :ractor do
+ expect(Ractor.shareable?(FFI::Type::INT32)).to eq(true)
+ end
+ end
+
+ describe :Mapped do
+ it "should be shareable with Ractor", :ractor do
+ converter = Module.new do
+ extend FFI::DataConverter
+
+ def self.native_type
+ FFI::Type::INT32
+ end
+
+ def self.to_native(val, ctx)
+ ToNativeMap[val]
+ end
+
+ def self.from_native(val, ctx)
+ FromNativeMap[val]
+ end
+ end
+ expect(Ractor.shareable?(converter)).to eq(true)
+ type = FFI::Type::Mapped.new(converter)
+ expect(Ractor.shareable?(type)).to eq(true)
+ end
+ end
end