summaryrefslogtreecommitdiff
path: root/spec/ruby/library/conditionvariable/wait_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/conditionvariable/wait_spec.rb')
-rw-r--r--spec/ruby/library/conditionvariable/wait_spec.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/ruby/library/conditionvariable/wait_spec.rb b/spec/ruby/library/conditionvariable/wait_spec.rb
new file mode 100644
index 0000000000..ddf6474212
--- /dev/null
+++ b/spec/ruby/library/conditionvariable/wait_spec.rb
@@ -0,0 +1,25 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'thread'
+
+describe "ConditionVariable#wait" do
+ it "returns self" do
+ m = Mutex.new
+ cv = ConditionVariable.new
+ in_synchronize = false
+
+ th = Thread.new do
+ m.synchronize do
+ in_synchronize = true
+ cv.wait(m).should == cv
+ end
+ end
+
+ # wait for m to acquire the mutex
+ Thread.pass until in_synchronize
+ # wait until th is sleeping (ie waiting)
+ Thread.pass while th.status and th.status != "sleep"
+
+ m.synchronize { cv.signal }
+ th.join
+ end
+end