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:
parent
34f8e75f93
commit
3d83e641b1
5 changed files with 24 additions and 16 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue