mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@875a09e
This commit is contained in:
parent
a06301b103
commit
5c276e1cc9
1247 changed files with 5316 additions and 5028 deletions
|
@ -14,12 +14,12 @@ describe "Mutex#lock" do
|
|||
it "blocks the caller if already locked" do
|
||||
m = Mutex.new
|
||||
m.lock
|
||||
lambda { m.lock }.should block_caller
|
||||
-> { m.lock }.should block_caller
|
||||
end
|
||||
|
||||
it "does not block the caller if not locked" do
|
||||
m = Mutex.new
|
||||
lambda { m.lock }.should_not block_caller
|
||||
-> { m.lock }.should_not block_caller
|
||||
end
|
||||
|
||||
# Unable to find a specific ticket but behavior change may be
|
||||
|
|
|
@ -4,21 +4,21 @@ describe "Mutex#sleep" do
|
|||
describe "when not locked by the current thread" do
|
||||
it "raises a ThreadError" do
|
||||
m = Mutex.new
|
||||
lambda { m.sleep }.should raise_error(ThreadError)
|
||||
-> { m.sleep }.should raise_error(ThreadError)
|
||||
end
|
||||
|
||||
it "raises an ArgumentError if passed a negative duration" do
|
||||
m = Mutex.new
|
||||
lambda { m.sleep(-0.1) }.should raise_error(ArgumentError)
|
||||
lambda { m.sleep(-1) }.should raise_error(ArgumentError)
|
||||
-> { m.sleep(-0.1) }.should raise_error(ArgumentError)
|
||||
-> { m.sleep(-1) }.should raise_error(ArgumentError)
|
||||
end
|
||||
end
|
||||
|
||||
it "raises an ArgumentError if passed a negative duration" do
|
||||
m = Mutex.new
|
||||
m.lock
|
||||
lambda { m.sleep(-0.1) }.should raise_error(ArgumentError)
|
||||
lambda { m.sleep(-1) }.should raise_error(ArgumentError)
|
||||
-> { m.sleep(-0.1) }.should raise_error(ArgumentError)
|
||||
-> { m.sleep(-1) }.should raise_error(ArgumentError)
|
||||
end
|
||||
|
||||
it "pauses execution for approximately the duration requested" do
|
||||
|
|
|
@ -8,7 +8,7 @@ describe "Mutex#synchronize" do
|
|||
synchronized = false
|
||||
|
||||
th = Thread.new do
|
||||
lambda do
|
||||
-> do
|
||||
m1.synchronize do
|
||||
synchronized = true
|
||||
m2.lock
|
||||
|
@ -28,12 +28,12 @@ describe "Mutex#synchronize" do
|
|||
it "blocks the caller if already locked" do
|
||||
m = Mutex.new
|
||||
m.lock
|
||||
lambda { m.synchronize { } }.should block_caller
|
||||
-> { m.synchronize { } }.should block_caller
|
||||
end
|
||||
|
||||
it "does not block the caller if not locked" do
|
||||
m = Mutex.new
|
||||
lambda { m.synchronize { } }.should_not block_caller
|
||||
-> { m.synchronize { } }.should_not block_caller
|
||||
end
|
||||
|
||||
it "blocks the caller if another thread is also in the synchronize block" do
|
||||
|
@ -50,7 +50,7 @@ describe "Mutex#synchronize" do
|
|||
|
||||
q1.pop.should == :ready
|
||||
|
||||
lambda { m.synchronize { } }.should block_caller
|
||||
-> { m.synchronize { } }.should block_caller
|
||||
|
||||
q2.push :done
|
||||
t.join
|
||||
|
@ -60,7 +60,7 @@ describe "Mutex#synchronize" do
|
|||
m = Mutex.new
|
||||
|
||||
m.synchronize do
|
||||
lambda { m.synchronize { } }.should raise_error(ThreadError)
|
||||
-> { m.synchronize { } }.should raise_error(ThreadError)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ require_relative '../../spec_helper'
|
|||
describe "Mutex#unlock" do
|
||||
it "raises ThreadError unless Mutex is locked" do
|
||||
mutex = Mutex.new
|
||||
lambda { mutex.unlock }.should raise_error(ThreadError)
|
||||
-> { mutex.unlock }.should raise_error(ThreadError)
|
||||
end
|
||||
|
||||
it "raises ThreadError unless thread owns Mutex" do
|
||||
|
@ -19,7 +19,7 @@ describe "Mutex#unlock" do
|
|||
Thread.pass until mutex.locked?
|
||||
Thread.pass while th.status and th.status != "sleep"
|
||||
|
||||
lambda { mutex.unlock }.should raise_error(ThreadError)
|
||||
-> { mutex.unlock }.should raise_error(ThreadError)
|
||||
|
||||
wait.unlock
|
||||
th.join
|
||||
|
@ -33,6 +33,6 @@ describe "Mutex#unlock" do
|
|||
|
||||
th.join
|
||||
|
||||
lambda { mutex.unlock }.should raise_error(ThreadError)
|
||||
-> { mutex.unlock }.should raise_error(ThreadError)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue