From 5fdcf2986dcab12dfb1df492a36fa298e49b9596 Mon Sep 17 00:00:00 2001 From: Andrey Lompart Date: Fri, 19 Jan 2024 13:30:14 +0800 Subject: [PATCH] Added test for timeout reduction --- test/unit/test_soft_timeout.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/unit/test_soft_timeout.rb b/test/unit/test_soft_timeout.rb index c8658a01..2a990e90 100644 --- a/test/unit/test_soft_timeout.rb +++ b/test/unit/test_soft_timeout.rb @@ -23,6 +23,17 @@ def test_extend_deadline timeout&.finished end + def test_reduce_deadline + called = [] + timeout = SoftTimeout.request(2.5, -> (thread) { called << thread }) + timeout.extend_deadline(-2) + sleep 1 + assert_equal [Thread.current], called + assert_predicate timeout, :done? + ensure + timeout&.finished + end + def test_cancel called = [] timeout = SoftTimeout.request(0.5, -> (thread) { called << thread })