diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-02-21 15:38:59 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-02-21 15:38:59 +0000 |
commit | da7976235fbc2986925969646071bebe3702e49f (patch) | |
tree | 83bbf6a8e03cf990369feabe6c1c9d45c69f4c85 /spec/ruby/core/thread/new_spec.rb | |
parent | b8e389a0f3226c90e96e02e6396686a3bef6a456 (diff) | |
download | ruby-da7976235fbc2986925969646071bebe3702e49f.tar.gz |
Update to ruby/spec@7a16e01
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core/thread/new_spec.rb')
-rw-r--r-- | spec/ruby/core/thread/new_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/ruby/core/thread/new_spec.rb b/spec/ruby/core/thread/new_spec.rb index c1e0e2a5ad..80929035c7 100644 --- a/spec/ruby/core/thread/new_spec.rb +++ b/spec/ruby/core/thread/new_spec.rb @@ -53,4 +53,31 @@ describe "Thread.new" do ScratchPad.recorded.should == [:good, :in_thread] end + it "releases Mutexes held by the Thread when the Thread finishes" do + m1 = Mutex.new + m2 = Mutex.new + t = Thread.new { + m1.lock + m1.locked?.should == true + m2.lock + m2.locked?.should == true + } + t.join + m1.locked?.should == false + m2.locked?.should == false + end + + it "releases Mutexes held by the Thread when the Thread finishes, also with Mutex#synchronize" do + m = Mutex.new + t = Thread.new { + m.synchronize { + m.unlock + m.lock + } + m.lock + m.locked?.should == true + } + t.join + m.locked?.should == false + end end |