diff options
author | John Bachir <jjb@users.noreply.github.com> | 2023-07-03 05:26:40 -0400 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-07-03 09:26:43 +0000 |
commit | 8281f8fd067017ac909bd16a66e64cfdfed06bc8 (patch) | |
tree | 12a3ad23748101aaa5f8565edaf03c310705e5bd /test | |
parent | 3e605a781970cef365002167634a1b5a176bffcb (diff) | |
download | ruby-8281f8fd067017ac909bd16a66e64cfdfed06bc8.tar.gz |
[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
Diffstat (limited to 'test')
-rw-r--r-- | test/test_timeout.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/test_timeout.rb b/test/test_timeout.rb index 236883aab4..0a8dc45cc3 100644 --- a/test/test_timeout.rb +++ b/test/test_timeout.rb @@ -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 } |