Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test that work is done in the same thread/fiber as the caller #34

Merged
merged 5 commits into from
Jul 3, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions test/test_timeout.rb
Original file line number Diff line number Diff line change
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 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