From 49a71439275089f91f37a03d91bfce71365eff85 Mon Sep 17 00:00:00 2001 From: Herwin Date: Thu, 14 Nov 2024 19:47:44 +0100 Subject: [PATCH] Refresh specs for Kernel.sleep This one has been removed from upstream for frequent failures, and it just failed on my test too. --- spec/core/kernel/sleep_spec.rb | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/spec/core/kernel/sleep_spec.rb b/spec/core/kernel/sleep_spec.rb index 1de52a707..4401e5425 100644 --- a/spec/core/kernel/sleep_spec.rb +++ b/spec/core/kernel/sleep_spec.rb @@ -51,18 +51,15 @@ def o.divmod(*); [0, 0.001]; end t.value.should == 5 end - platform_is_not :darwin do - it "sleeps with nanosecond precision" do - start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) - 100.times do - sleep(0.0001) - end - end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) - - actual_duration = end_time - start_time - (actual_duration > 0.01).should == true # 100 * 0.0001 => 0.01 - (actual_duration < 0.03).should == true + it "sleeps with nanosecond precision" do + start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) + 100.times do + sleep(0.0001) end + end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) + + actual_duration = end_time - start_time + actual_duration.should > 0.01 # 100 * 0.0001 => 0.01 end ruby_version_is ""..."3.3" do