From 2bff039ea1400fbbac530289b6f1c47585318859 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Mon, 26 May 2025 18:10:26 +0900 Subject: [PATCH] Use `Ractor#value` as `Ractor#take` is removed To keep compatibility with older Rubys, left `alias value take`. See https://bugs.ruby-lang.org/issues/21262 --- test/ostruct/test_ostruct.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb index 19bb606..616f84d 100644 --- a/test/ostruct/test_ostruct.rb +++ b/test/ostruct/test_ostruct.rb @@ -358,26 +358,34 @@ def []=(k, v) def test_ractor assert_ractor(<<~RUBY, require: 'ostruct') + class Ractor + alias value take + end unless Ractor.method_defined? :value # compat with Ruby 3.4 and olders + obj1 = OpenStruct.new(a: 42, b: 42) obj1.c = 42 obj1.freeze obj2 = Ractor.new obj1 do |obj| obj - end.take + end.value assert obj1.object_id == obj2.object_id RUBY end if defined?(Ractor) def test_access_methods_from_different_ractor assert_ractor(<<~RUBY, require: 'ostruct') + class Ractor + alias value take + end unless Ractor.method_defined? :value # compat with Ruby 3.4 and olders + os = OpenStruct.new os.value = 100 r = Ractor.new(os) do |x| v = x.value - Ractor.yield v + v end - assert 100 == r.take + assert 100 == r.value RUBY end if defined?(Ractor)