Skip to content

Commit

Permalink
Test that work is done in the same thread/fiber as the caller (#34)
Browse files Browse the repository at this point in the history
* see discussion in
#30 (comment)
  • Loading branch information
jjb committed Jul 3, 2023
1 parent d5eb74f commit 2d2959c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/test_timeout.rb
Expand Up @@ -4,6 +4,15 @@

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 }
Expand Down

0 comments on commit 2d2959c

Please sign in to comment.