summaryrefslogtreecommitdiff
path: root/spec/ruby/core/thread
diff options
context:
space:
mode:
authorBenoit Daloze <[email protected]>2019-07-27 12:40:09 +0200
committerBenoit Daloze <[email protected]>2019-07-27 12:40:09 +0200
commit5c276e1cc91c5ab2a41fbf7827af2fed914a2bc0 (patch)
tree05b5c68c8b2a00224d4646ea3b26ce3877efaadd /spec/ruby/core/thread
parenta06301b103371b0b7da8eaca26ba744961769f99 (diff)
Update to ruby/spec@875a09e
Diffstat (limited to 'spec/ruby/core/thread')
-rw-r--r--spec/ruby/core/thread/abort_on_exception_spec.rb2
-rw-r--r--spec/ruby/core/thread/allocate_spec.rb2
-rw-r--r--spec/ruby/core/thread/backtrace/location/fixtures/main.rb4
-rw-r--r--spec/ruby/core/thread/element_reference_spec.rb4
-rw-r--r--spec/ruby/core/thread/element_set_spec.rb4
-rw-r--r--spec/ruby/core/thread/exclusive_spec.rb4
-rw-r--r--spec/ruby/core/thread/fixtures/classes.rb9
-rw-r--r--spec/ruby/core/thread/initialize_spec.rb2
-rw-r--r--spec/ruby/core/thread/join_spec.rb20
-rw-r--r--spec/ruby/core/thread/key_spec.rb4
-rw-r--r--spec/ruby/core/thread/list_spec.rb6
-rw-r--r--spec/ruby/core/thread/name_spec.rb2
-rw-r--r--spec/ruby/core/thread/new_spec.rb12
-rw-r--r--spec/ruby/core/thread/priority_spec.rb2
-rw-r--r--spec/ruby/core/thread/shared/exit.rb2
-rw-r--r--spec/ruby/core/thread/shared/start.rb2
-rw-r--r--spec/ruby/core/thread/shared/wakeup.rb2
-rw-r--r--spec/ruby/core/thread/value_spec.rb12
18 files changed, 49 insertions, 46 deletions
diff --git a/spec/ruby/core/thread/abort_on_exception_spec.rb b/spec/ruby/core/thread/abort_on_exception_spec.rb
index 88de77b1a8..34b648ca0f 100644
--- a/spec/ruby/core/thread/abort_on_exception_spec.rb
+++ b/spec/ruby/core/thread/abort_on_exception_spec.rb
@@ -35,7 +35,7 @@ describe :thread_abort_on_exception, shared: true do
ScratchPad << :before
@thread.abort_on_exception = true if @object
- lambda do
+ -> do
ThreadSpecs.state = :run
# Wait for the main thread to be interrupted
sleep
diff --git a/spec/ruby/core/thread/allocate_spec.rb b/spec/ruby/core/thread/allocate_spec.rb
index cd9aa1ee43..cfd556812f 100644
--- a/spec/ruby/core/thread/allocate_spec.rb
+++ b/spec/ruby/core/thread/allocate_spec.rb
@@ -2,7 +2,7 @@ require_relative '../../spec_helper'
describe "Thread.allocate" do
it "raises a TypeError" do
- lambda {
+ -> {
Thread.allocate
}.should raise_error(TypeError)
end
diff --git a/spec/ruby/core/thread/backtrace/location/fixtures/main.rb b/spec/ruby/core/thread/backtrace/location/fixtures/main.rb
index d2d14ac957..bde208a059 100644
--- a/spec/ruby/core/thread/backtrace/location/fixtures/main.rb
+++ b/spec/ruby/core/thread/backtrace/location/fixtures/main.rb
@@ -1,5 +1,5 @@
-def example
+def backtrace_location_example
caller_locations[0].path
end
-print example
+print backtrace_location_example
diff --git a/spec/ruby/core/thread/element_reference_spec.rb b/spec/ruby/core/thread/element_reference_spec.rb
index 4de33e1456..85280cb287 100644
--- a/spec/ruby/core/thread/element_reference_spec.rb
+++ b/spec/ruby/core/thread/element_reference_spec.rb
@@ -38,7 +38,7 @@ describe "Thread#[]" do
end
it "raises exceptions on the wrong type of keys" do
- lambda { Thread.current[nil] }.should raise_error(TypeError)
- lambda { Thread.current[5] }.should raise_error(TypeError)
+ -> { Thread.current[nil] }.should raise_error(TypeError)
+ -> { Thread.current[5] }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/thread/element_set_spec.rb b/spec/ruby/core/thread/element_set_spec.rb
index c109468a5e..d974b5e1c7 100644
--- a/spec/ruby/core/thread/element_set_spec.rb
+++ b/spec/ruby/core/thread/element_set_spec.rb
@@ -17,8 +17,8 @@ describe "Thread#[]=" do
end
it "raises exceptions on the wrong type of keys" do
- lambda { Thread.current[nil] = true }.should raise_error(TypeError)
- lambda { Thread.current[5] = true }.should raise_error(TypeError)
+ -> { Thread.current[nil] = true }.should raise_error(TypeError)
+ -> { Thread.current[5] = true }.should raise_error(TypeError)
end
it "is not shared across fibers" do
diff --git a/spec/ruby/core/thread/exclusive_spec.rb b/spec/ruby/core/thread/exclusive_spec.rb
index 9de427fb52..a96ebe749d 100644
--- a/spec/ruby/core/thread/exclusive_spec.rb
+++ b/spec/ruby/core/thread/exclusive_spec.rb
@@ -28,7 +28,7 @@ describe "Thread.exclusive" do
q1.pop.should == :ready
- lambda { Thread.exclusive { } }.should block_caller
+ -> { Thread.exclusive { } }.should block_caller
q2.push :done
t.join
@@ -36,7 +36,7 @@ describe "Thread.exclusive" do
it "is not recursive" do
Thread.exclusive do
- lambda { Thread.exclusive { } }.should raise_error(ThreadError)
+ -> { Thread.exclusive { } }.should raise_error(ThreadError)
end
end
end
diff --git a/spec/ruby/core/thread/fixtures/classes.rb b/spec/ruby/core/thread/fixtures/classes.rb
index 601e515e3e..c1f15935ee 100644
--- a/spec/ruby/core/thread/fixtures/classes.rb
+++ b/spec/ruby/core/thread/fixtures/classes.rb
@@ -1,10 +1,3 @@
-unless defined? Channel
- require 'thread'
- class Channel < Queue
- alias receive shift
- end
-end
-
module ThreadSpecs
class SubThread < Thread
@@ -188,7 +181,7 @@ module ThreadSpecs
def self.join_dying_thread_with_outer_ensure(kill_method_name=:kill)
t = dying_thread_with_outer_ensure(kill_method_name) { yield }
- lambda { t.join }.should raise_error(RuntimeError, "In dying thread")
+ -> { t.join }.should raise_error(RuntimeError, "In dying thread")
return t
end
diff --git a/spec/ruby/core/thread/initialize_spec.rb b/spec/ruby/core/thread/initialize_spec.rb
index 80e058a120..4fca900cd8 100644
--- a/spec/ruby/core/thread/initialize_spec.rb
+++ b/spec/ruby/core/thread/initialize_spec.rb
@@ -15,7 +15,7 @@ describe "Thread#initialize" do
end
it "raises a ThreadError" do
- lambda {
+ -> {
@t.instance_eval do
initialize {}
end
diff --git a/spec/ruby/core/thread/join_spec.rb b/spec/ruby/core/thread/join_spec.rb
index f60f91e436..f3c5cdc1ed 100644
--- a/spec/ruby/core/thread/join_spec.rb
+++ b/spec/ruby/core/thread/join_spec.rb
@@ -19,28 +19,28 @@ describe "Thread#join" do
t.join(0).should equal(t)
t.join(0.0).should equal(t)
t.join(nil).should equal(t)
- lambda { t.join(:foo) }.should raise_error TypeError
- lambda { t.join("bar") }.should raise_error TypeError
+ -> { t.join(:foo) }.should raise_error TypeError
+ -> { t.join("bar") }.should raise_error TypeError
end
it "returns nil if it is not finished when given a timeout" do
- c = Channel.new
- t = Thread.new { c.receive }
+ q = Queue.new
+ t = Thread.new { q.pop }
begin
t.join(0).should == nil
ensure
- c << true
+ q << true
end
t.join.should == t
end
it "accepts a floating point timeout length" do
- c = Channel.new
- t = Thread.new { c.receive }
+ q = Queue.new
+ t = Thread.new { q.pop }
begin
t.join(0.01).should == nil
ensure
- c << true
+ q << true
end
t.join.should == t
end
@@ -50,7 +50,7 @@ describe "Thread#join" do
Thread.current.report_on_exception = false
raise NotImplementedError.new("Just kidding")
}
- lambda { t.join }.should raise_error(NotImplementedError)
+ -> { t.join }.should raise_error(NotImplementedError)
end
it "returns the dead thread" do
@@ -60,6 +60,6 @@ describe "Thread#join" do
it "raises any uncaught exception encountered in ensure block" do
t = ThreadSpecs.dying_thread_ensures { raise NotImplementedError.new("Just kidding") }
- lambda { t.join }.should raise_error(NotImplementedError)
+ -> { t.join }.should raise_error(NotImplementedError)
end
end
diff --git a/spec/ruby/core/thread/key_spec.rb b/spec/ruby/core/thread/key_spec.rb
index c4ed0f9c0d..6940cf5f28 100644
--- a/spec/ruby/core/thread/key_spec.rb
+++ b/spec/ruby/core/thread/key_spec.rb
@@ -17,8 +17,8 @@ describe "Thread#key?" do
end
it "raises exceptions on the wrong type of keys" do
- lambda { Thread.current.key? nil }.should raise_error(TypeError)
- lambda { Thread.current.key? 5 }.should raise_error(TypeError)
+ -> { Thread.current.key? nil }.should raise_error(TypeError)
+ -> { Thread.current.key? 5 }.should raise_error(TypeError)
end
it "is not shared across fibers" do
diff --git a/spec/ruby/core/thread/list_spec.rb b/spec/ruby/core/thread/list_spec.rb
index 80dd15c6ca..a0bf831856 100644
--- a/spec/ruby/core/thread/list_spec.rb
+++ b/spec/ruby/core/thread/list_spec.rb
@@ -25,13 +25,13 @@ describe "Thread.list" do
end
it "includes waiting threads" do
- c = Channel.new
- t = Thread.new { c.receive }
+ q = Queue.new
+ t = Thread.new { q.pop }
begin
Thread.pass while t.status and t.status != 'sleep'
Thread.list.should include(t)
ensure
- c << nil
+ q << nil
t.join
end
end
diff --git a/spec/ruby/core/thread/name_spec.rb b/spec/ruby/core/thread/name_spec.rb
index adb2d08fae..9b3d2f4b09 100644
--- a/spec/ruby/core/thread/name_spec.rb
+++ b/spec/ruby/core/thread/name_spec.rb
@@ -34,7 +34,7 @@ describe "Thread#name=" do
end
it "raises an ArgumentError if the name includes a null byte" do
- lambda {
+ -> {
@thread.name = "new thread\0name"
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/core/thread/new_spec.rb b/spec/ruby/core/thread/new_spec.rb
index 80929035c7..3a57149381 100644
--- a/spec/ruby/core/thread/new_spec.rb
+++ b/spec/ruby/core/thread/new_spec.rb
@@ -3,10 +3,10 @@ require_relative 'fixtures/classes'
describe "Thread.new" do
it "creates a thread executing the given block" do
- c = Channel.new
- Thread.new { c << true }.join
- c << false
- c.receive.should == true
+ q = Queue.new
+ Thread.new { q << true }.join
+ q << false
+ q.pop.should == true
end
it "can pass arguments to the thread block" do
@@ -18,7 +18,7 @@ describe "Thread.new" do
end
it "raises an exception when not given a block" do
- lambda { Thread.new }.should raise_error(ThreadError)
+ -> { Thread.new }.should raise_error(ThreadError)
end
it "creates a subclass of thread calls super with a block in initialize" do
@@ -34,7 +34,7 @@ describe "Thread.new" do
end
end
- lambda {
+ -> {
c.new
}.should raise_error(ThreadError)
end
diff --git a/spec/ruby/core/thread/priority_spec.rb b/spec/ruby/core/thread/priority_spec.rb
index 5da6216b53..e13ad478b5 100644
--- a/spec/ruby/core/thread/priority_spec.rb
+++ b/spec/ruby/core/thread/priority_spec.rb
@@ -59,7 +59,7 @@ describe "Thread#priority=" do
describe "when set with a non-integer" do
it "raises a type error" do
- lambda{ @thread.priority = Object.new }.should raise_error(TypeError)
+ ->{ @thread.priority = Object.new }.should raise_error(TypeError)
end
end
diff --git a/spec/ruby/core/thread/shared/exit.rb b/spec/ruby/core/thread/shared/exit.rb
index 4686b7b28b..40dc478947 100644
--- a/spec/ruby/core/thread/shared/exit.rb
+++ b/spec/ruby/core/thread/shared/exit.rb
@@ -116,7 +116,7 @@ describe :thread_exit, shared: true do
it "propagates inner exception to Thread.join if there is an outer ensure clause" do
thread = ThreadSpecs.dying_thread_with_outer_ensure(@method) { }
- lambda { thread.join }.should raise_error(RuntimeError, "In dying thread")
+ -> { thread.join }.should raise_error(RuntimeError, "In dying thread")
end
it "runs all outer ensure clauses even if inner ensure clause raises exception" do
diff --git a/spec/ruby/core/thread/shared/start.rb b/spec/ruby/core/thread/shared/start.rb
index 80ce063a0e..2ba926bf00 100644
--- a/spec/ruby/core/thread/shared/start.rb
+++ b/spec/ruby/core/thread/shared/start.rb
@@ -4,7 +4,7 @@ describe :thread_start, shared: true do
end
it "raises an ArgumentError if not passed a block" do
- lambda {
+ -> {
Thread.send(@method)
}.should raise_error(ArgumentError)
end
diff --git a/spec/ruby/core/thread/shared/wakeup.rb b/spec/ruby/core/thread/shared/wakeup.rb
index 71838d88e5..f111edf0fd 100644
--- a/spec/ruby/core/thread/shared/wakeup.rb
+++ b/spec/ruby/core/thread/shared/wakeup.rb
@@ -56,6 +56,6 @@ describe :thread_wakeup, shared: true do
it "raises a ThreadError when trying to wake up a dead thread" do
t = Thread.new { 1 }
t.join
- lambda { t.send @method }.should raise_error(ThreadError)
+ -> { t.send @method }.should raise_error(ThreadError)
end
end
diff --git a/spec/ruby/core/thread/value_spec.rb b/spec/ruby/core/thread/value_spec.rb
index 30b12db125..30e43abd1a 100644
--- a/spec/ruby/core/thread/value_spec.rb
+++ b/spec/ruby/core/thread/value_spec.rb
@@ -11,11 +11,21 @@ describe "Thread#value" do
Thread.current.report_on_exception = false
raise "Hello"
}
- lambda { t.value }.should raise_error(RuntimeError, "Hello")
+ -> { t.value }.should raise_error(RuntimeError, "Hello")
end
it "is nil for a killed thread" do
t = Thread.new { Thread.current.exit }
t.value.should == nil
end
+
+ it "returns when the thread finished" do
+ q = Queue.new
+ t = Thread.new {
+ q.pop
+ }
+ -> { t.value }.should block_caller
+ q.push :result
+ t.value.should == :result
+ end
end