summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2021-02-12 15:06:07 +1300
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2021-03-30 18:38:42 +1300
commitaf1c587546c34190721bb8b72e86985e9b79bdc6 (patch)
tree4560e2e0cb342a7e0fa1e585f600f906a9e53c49
parent511acba4aeb3e35cf025a8a6cde4241b7b5167f3 (diff)
Improve timeout tests.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4173
-rw-r--r--test/fiber/test_timeout.rb21
1 files changed, 20 insertions, 1 deletions
diff --git a/test/fiber/test_timeout.rb b/test/fiber/test_timeout.rb
index 127e4b0..c17092b 100644
--- a/test/fiber/test_timeout.rb
+++ b/test/fiber/test_timeout.rb
@@ -14,7 +14,7 @@ class TestFiberTimeout < Test::Unit::TestCase
Fiber.schedule do
begin
- Timeout.timeout(0.01) do
+ Timeout.timeout(0.001) do
sleep(1)
end
rescue
@@ -27,4 +27,23 @@ class TestFiberTimeout < Test::Unit::TestCase
assert_kind_of(Timeout::Error, error)
end
+
+ MESSAGE = "Hello World"
+
+ def test_timeout_on_main_fiber
+ message = nil
+
+ thread = Thread.new do
+ scheduler = Scheduler.new
+ Fiber.set_scheduler scheduler
+
+ Timeout.timeout(1) do
+ message = MESSAGE
+ end
+ end
+
+ thread.join
+
+ assert_equal MESSAGE, message
+ end
end