Skip to content

Commit 50d5124

Browse files
ko1hsbt
authored andcommitted
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
1 parent 7ee2fe7 commit 50d5124

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

test/ostruct/test_ostruct.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,26 +358,34 @@ def []=(k, v)
358358

359359
def test_ractor
360360
assert_ractor(<<~RUBY, require: 'ostruct')
361+
class Ractor
362+
alias value take
363+
end unless Ractor.method_defined? :value # compat with Ruby 3.4 and olders
364+
361365
obj1 = OpenStruct.new(a: 42, b: 42)
362366
obj1.c = 42
363367
obj1.freeze
364368
365369
obj2 = Ractor.new obj1 do |obj|
366370
obj
367-
end.take
371+
end.value
368372
assert obj1.object_id == obj2.object_id
369373
RUBY
370374
end if defined?(Ractor)
371375

372376
def test_access_methods_from_different_ractor
373377
assert_ractor(<<~RUBY, require: 'ostruct')
378+
class Ractor
379+
alias value take
380+
end unless Ractor.method_defined? :value # compat with Ruby 3.4 and olders
381+
374382
os = OpenStruct.new
375383
os.value = 100
376384
r = Ractor.new(os) do |x|
377385
v = x.value
378-
Ractor.yield v
386+
v
379387
end
380-
assert 100 == r.take
388+
assert 100 == r.value
381389
RUBY
382390
end if defined?(Ractor)
383391

0 commit comments

Comments
 (0)