[ruby/tmpdir] Restore Ractor.yield style test for old version of Ruby

https://github.com/ruby/tmpdir/commit/f12c766996
This commit is contained in:
Hiroshi SHIBATA 2025-06-03 16:49:10 +09:00
parent 365d5b6bf4
commit 135583e37c
No known key found for this signature in database
GPG Key ID: F9CF13417264FAC2

View File

@ -134,6 +134,7 @@ class TestTmpdir < Test::Unit::TestCase
def test_ractor def test_ractor
assert_ractor(<<~'end;', require: "tmpdir") assert_ractor(<<~'end;', require: "tmpdir")
if defined?(Ractor::Port)
port = Ractor::Port.new port = Ractor::Port.new
r = Ractor.new port do |port| r = Ractor.new port do |port|
Dir.mktmpdir() do |d| Dir.mktmpdir() do |d|
@ -146,6 +147,19 @@ class TestTmpdir < Test::Unit::TestCase
r.send true r.send true
r.join r.join
assert_file.not_exist? dir 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
end; end;
end end
end end