summaryrefslogtreecommitdiff
path: root/bootstraptest
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-09-25 11:39:15 +0900
committerKoichi Sasada <ko1@atdot.net>2020-09-25 12:53:58 +0900
commitd247dedade684d8ba04da4af891791e5ab5878ef (patch)
tree710e24f7f84d91d58d014cbba809d8d06f65b6eb /bootstraptest
parent52865263467b48c0f5af6d9548972dd1f9e5bee1 (diff)
Ractor.yield should raise if out-port is closed
Ractor.yield should raise Ractor::ClosedError if current Ractor's outgoing-port is closed.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3578
Diffstat (limited to 'bootstraptest')
-rw-r--r--bootstraptest/test_ractor.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb
index c693a9c496..025d886152 100644
--- a/bootstraptest/test_ractor.rb
+++ b/bootstraptest/test_ractor.rb
@@ -225,6 +225,27 @@ assert_equal 'ok', %q{
end
}
+# Ractor.yield raises Ractor::ClosedError when outgoing port is closed.
+assert_equal 'ok', %q{
+ r = Ractor.new Ractor.current do |main|
+ Ractor.recv
+ main << true
+ Ractor.yield 1
+ end
+
+ r.close_outgoing
+ r << true
+ Ractor.recv
+
+ begin
+ r.take
+ rescue Ractor::ClosedError
+ 'ok'
+ else
+ 'ng'
+ end
+}
+
# Raise Ractor::ClosedError when try to send into a ractor with closed incoming port
assert_equal 'ok', %q{
r = Ractor.new { Ractor.recv }