Skip to content

Commit 2d2959c

Browse files
authored
Test that work is done in the same thread/fiber as the caller (#34)
* see discussion in #30 (comment)
1 parent d5eb74f commit 2d2959c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/test_timeout.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44

55
class TestTimeout < Test::Unit::TestCase
66

7+
def test_work_is_done_in_same_thread_as_caller
8+
assert_equal Thread.current, Timeout.timeout(10){ Thread.current }
9+
end
10+
11+
def test_work_is_done_in_same_fiber_as_caller
12+
require 'fiber' # needed for ruby 3.0 and lower
13+
assert_equal Fiber.current, Timeout.timeout(10){ Fiber.current }
14+
end
15+
716
def test_non_timing_out_code_is_successful
817
assert_nothing_raised do
918
assert_equal :ok, Timeout.timeout(1){ :ok }

0 commit comments

Comments
 (0)