diff options
Diffstat (limited to 'spec/ruby/core/thread/current_spec.rb')
-rw-r--r-- | spec/ruby/core/thread/current_spec.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/ruby/core/thread/current_spec.rb b/spec/ruby/core/thread/current_spec.rb index cc969b71c4..6c4dcfae43 100644 --- a/spec/ruby/core/thread/current_spec.rb +++ b/spec/ruby/core/thread/current_spec.rb @@ -12,4 +12,20 @@ describe "Thread.current" do t.value.should equal(t) Thread.current.should_not equal(t.value) end + + it "returns the correct thread in a Fiber" do + # This catches a bug where Fibers are running on a thread-pool + # and Fibers from a different Ruby Thread reuse the same native thread. + # Caching the Ruby Thread based on the native thread is not correct in that case. + 2.times do + t = Thread.new { + cur = Thread.current + Fiber.new { + Thread.current + }.resume.should equal cur + cur + } + t.value.should equal t + end + end end |