summaryrefslogtreecommitdiff
path: root/test/fiber/test_scheduler.rb
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-09-20 11:34:02 +1200
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2020-09-21 09:51:33 +1200
commit501fff14c7657f769d68f90de98fd2ebccb807fb (patch)
tree10dfcaf36b27dcd6b83268f9b0de2516fed41ec2 /test/fiber/test_scheduler.rb
parentb6d599d76ec85422bea16b63f105985cf08e04bd (diff)
When setting current thread scheduler to nil, invoke `#close`.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3557
Diffstat (limited to 'test/fiber/test_scheduler.rb')
-rw-r--r--test/fiber/test_scheduler.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/fiber/test_scheduler.rb b/test/fiber/test_scheduler.rb
index 7acf63d9b8..23fd8b4493 100644
--- a/test/fiber/test_scheduler.rb
+++ b/test/fiber/test_scheduler.rb
@@ -10,4 +10,29 @@ class TestFiberScheduler < Test::Unit::TestCase
end
end
end
+
+ def test_closed_at_thread_exit
+ scheduler = Scheduler.new
+
+ thread = Thread.new do
+ Thread.current.scheduler = scheduler
+ end
+
+ thread.join
+
+ assert scheduler.closed?
+ end
+
+ def test_closed_when_set_to_nil
+ scheduler = Scheduler.new
+
+ thread = Thread.new do
+ Thread.current.scheduler = scheduler
+ Thread.current.scheduler = nil
+
+ assert scheduler.closed?
+ end
+
+ thread.join
+ end
end