diff options
author | Hiroshi SHIBATA <[email protected]> | 2025-06-03 16:49:10 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2025-06-03 18:13:15 +0900 |
commit | 135583e37c06267debf77ee60a8540dfe70bec8f (patch) | |
tree | 4e74a3ad953241f3a7afcddf28874d69c0f144fe /test | |
parent | 365d5b6bf44e4779af0abaf5fee7af9c7c39d224 (diff) |
[ruby/tmpdir] Restore Ractor.yield style test for old version of Ruby
https://github.com/ruby/tmpdir/commit/f12c766996
Diffstat (limited to 'test')
-rw-r--r-- | test/test_tmpdir.rb | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/test/test_tmpdir.rb b/test/test_tmpdir.rb index 789f433d7b..c91fc334ed 100644 --- a/test/test_tmpdir.rb +++ b/test/test_tmpdir.rb @@ -134,18 +134,32 @@ class TestTmpdir < Test::Unit::TestCase def test_ractor assert_ractor(<<~'end;', require: "tmpdir") - port = Ractor::Port.new - r = Ractor.new port do |port| - Dir.mktmpdir() do |d| - port << d - Ractor.receive + if defined?(Ractor::Port) + port = Ractor::Port.new + r = Ractor.new port do |port| + Dir.mktmpdir() do |d| + port << d + Ractor.receive + end + end + dir = port.receive + assert_file.directory? dir + r.send true + r.join + assert_file.not_exist? dir + else + r = Ractor.new do + Dir.mktmpdir() do |d| + Ractor.yield d + Ractor.receive + end end + dir = r.take + assert_file.directory? dir + r.send true + r.take + assert_file.not_exist? dir end - dir = port.receive - assert_file.directory? dir - r.send true - r.join - assert_file.not_exist? dir end; end end |