mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
[ruby/tmpdir] Restore Ractor.yield style test for old version of Ruby
f12c766996
This commit is contained in:
parent
365d5b6bf4
commit
135583e37c
1 changed files with 24 additions and 10 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue