ruby-changes:65706
From: Samuel <ko1@a...>
Date: Tue, 30 Mar 2021 14:39:02 +0900 (JST)
Subject: [ruby-changes:65706] af1c587546 (master): Improve timeout tests.
https://git.ruby-lang.org/ruby.git/commit/?id=af1c587546 From af1c587546c34190721bb8b72e86985e9b79bdc6 Mon Sep 17 00:00:00 2001 From: Samuel Williams <samuel.williams@o...> Date: Fri, 12 Feb 2021 15:06:07 +1300 Subject: Improve timeout tests. --- test/fiber/test_timeout.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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 https://github.com/ruby/ruby/blob/trunk/test/fiber/test_timeout.rb#L14 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 https://github.com/ruby/ruby/blob/trunk/test/fiber/test_timeout.rb#L27 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 -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/