1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/spec] Check by Thread#stop?

Check if threads are stopped by Thread#stop? instead of the status
name.
This commit is contained in:
Nobuyoshi Nakada 2020-02-06 13:36:02 +09:00
parent 34f8e75f93
commit 3d83e641b1
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
5 changed files with 24 additions and 16 deletions

View file

@ -37,7 +37,7 @@ describe "Mutex#sleep" do
locked = false
th = Thread.new { m.lock; locked = true; m.sleep }
Thread.pass until locked
Thread.pass while th.status and th.status != "sleep"
Thread.pass until th.stop?
m.locked?.should be_false
th.run
th.join
@ -63,15 +63,23 @@ describe "Mutex#sleep" do
end
end
Thread.pass until locked
Thread.pass while th.status and th.status != "sleep"
Thread.pass until th.stop?
th.raise(Exception)
th.value.should be_true
end
it "returns the rounded number of seconds asleep" do
m = Mutex.new
m.lock
m.sleep(0.001).should be_kind_of(Integer)
locked = false
th = Thread.start do
m.lock
locked = true
m.sleep
end
Thread.pass until locked
Thread.pass until th.stop?
th.wakeup
th.value.should be_kind_of(Integer)
end
it "wakes up when requesting sleep times near or equal to zero" do