diff options
Diffstat (limited to 'spec/ruby/core/mutex')
-rw-r--r-- | spec/ruby/core/mutex/sleep_spec.rb | 16 | ||||
-rw-r--r-- | spec/ruby/core/mutex/unlock_spec.rb | 2 |
2 files changed, 13 insertions, 5 deletions
diff --git a/spec/ruby/core/mutex/sleep_spec.rb b/spec/ruby/core/mutex/sleep_spec.rb index f5e0d53036..6638f5a5a2 100644 --- a/spec/ruby/core/mutex/sleep_spec.rb +++ b/spec/ruby/core/mutex/sleep_spec.rb @@ -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 diff --git a/spec/ruby/core/mutex/unlock_spec.rb b/spec/ruby/core/mutex/unlock_spec.rb index c9c3bfe14f..d999e66842 100644 --- a/spec/ruby/core/mutex/unlock_spec.rb +++ b/spec/ruby/core/mutex/unlock_spec.rb @@ -17,7 +17,7 @@ describe "Mutex#unlock" do # avoid race on mutex.lock Thread.pass until mutex.locked? - Thread.pass while th.status and th.status != "sleep" + Thread.pass until th.stop? -> { mutex.unlock }.should raise_error(ThreadError) |