[ruby/timeout] Test that work is done in the same thread/fiber as
the caller (https://github.com/ruby/timeout/pull/34) * see discussion in https://github.com/ruby/timeout/pull/30#issuecomment-1616179651
This commit is contained in:
parent
3e605a7819
commit
8281f8fd06
@ -4,6 +4,15 @@ require 'timeout'
|
||||
|
||||
class TestTimeout < Test::Unit::TestCase
|
||||
|
||||
def test_work_is_done_in_same_thread_as_caller
|
||||
assert_equal Thread.current, Timeout.timeout(10){ Thread.current }
|
||||
end
|
||||
|
||||
def test_work_is_done_in_same_fiber_as_caller
|
||||
require 'fiber' # needed for ruby 3.0 and lower
|
||||
assert_equal Fiber.current, Timeout.timeout(10){ Fiber.current }
|
||||
end
|
||||
|
||||
def test_non_timing_out_code_is_successful
|
||||
assert_nothing_raised do
|
||||
assert_equal :ok, Timeout.timeout(1){ :ok }
|
||||
|
Loading…
x
Reference in New Issue
Block a user