diff options
Diffstat (limited to 'spec/ruby/library')
-rw-r--r-- | spec/ruby/library/conditionvariable/wait_spec.rb | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/spec/ruby/library/conditionvariable/wait_spec.rb b/spec/ruby/library/conditionvariable/wait_spec.rb index 99e14efe35..d4950a7b27 100644 --- a/spec/ruby/library/conditionvariable/wait_spec.rb +++ b/spec/ruby/library/conditionvariable/wait_spec.rb @@ -23,15 +23,21 @@ describe "ConditionVariable#wait" do th.join end - it "the lock remains usable even if the thread is killed" do + it "reacquires the lock even if the thread is killed" do m = Mutex.new cv = ConditionVariable.new in_synchronize = false + owned = nil th = Thread.new do m.synchronize do in_synchronize = true - cv.wait(m) + begin + cv.wait(m) + ensure + owned = m.owned? + $stderr.puts "\nThe Thread doesn't own the Mutex!" unless owned + end end end @@ -43,19 +49,24 @@ describe "ConditionVariable#wait" do th.kill th.join - m.try_lock.should == true - m.unlock + owned.should == true end - it "lock remains usable even if the thread is killed after being signaled" do + it "reacquires the lock even if the thread is killed after being signaled" do m = Mutex.new cv = ConditionVariable.new in_synchronize = false + owned = nil th = Thread.new do m.synchronize do in_synchronize = true - cv.wait(m) + begin + cv.wait(m) + ensure + owned = m.owned? + $stderr.puts "\nThe Thread doesn't own the Mutex!" unless owned + end end end @@ -73,8 +84,7 @@ describe "ConditionVariable#wait" do } th.join - m.try_lock.should == true - m.unlock + owned.should == true end it "supports multiple Threads waiting on the same ConditionVariable and Mutex" do |