Skip to content

Commit

Permalink
Reenable sleep ns spec on MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Nov 6, 2024
1 parent a230079 commit 1a77146
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions core/kernel/sleep_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,16 @@ 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 > 0.01).should == true # 100 * 0.0001 => 0.01
(actual_duration < 0.03).should == true
end

ruby_version_is ""..."3.3" do
Expand Down

0 comments on commit 1a77146

Please sign in to comment.