Skip to content

Commit 0a679ed

Browse files
committed
Test timeout on join
Achieve 100% line coverage. Closes #5
1 parent c09c38e commit 0a679ed

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

‎test/test_psyllium.rb‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,21 @@ def test_join_works
201201
assert_equal(fiber1, fiber1.join)
202202
end
203203
end
204+
205+
def test_timeout_works
206+
# Need to run this under a non-blocking Fiber, otherwise joining won't work.
207+
Fiber.schedule do
208+
fiber1 = ::Fiber.start do
209+
sleep(0.1)
210+
end
211+
212+
timeout_value1 = fiber1.join(0.05)
213+
214+
assert_nil(timeout_value1)
215+
216+
timeout_value2 = fiber1.join(0.15)
217+
218+
refute_nil(timeout_value2)
219+
end
220+
end
204221
end

0 commit comments

Comments
 (0)