diff options
author | Jeremy Evans <code@jeremyevans.net> | 2019-10-21 16:54:58 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-21 16:54:58 -0700 |
commit | fa8ac91e957a076f6df1adaecad7896817138009 (patch) | |
tree | c8871b6dd46412100ba615b99860bd5c081eacaa /test/ruby | |
parent | f37cc1c719f12d2cad6032aa4e6f4236f0604992 (diff) | |
download | ruby-fa8ac91e957a076f6df1adaecad7896817138009.tar.gz |
Fix Fiber#transfer
Fiber#transfer previously made it impossible to resume the fiber
if it was transferred to (no resuming the target of Fiber#transfer).
However, the documentation specifies that you cannot resume a fiber
that has transferred to another fiber (no resuming the source of
Fiber#transfer), unless control is transferred back.
Fix the code by setting the transferred flag on the current/source
fiber, and unsetting the transferred flag on the target fiber.
Fixes [Bug #9664]
Fixes [Bug #12555]
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_fiber.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb index 2d7cbc8a9e..aa47aaf9be 100644 --- a/test/ruby/test_fiber.rb +++ b/test/ruby/test_fiber.rb @@ -222,8 +222,8 @@ class TestFiber < Test::Unit::TestCase end def test_resume_self - f = Fiber.new {f.resume} - assert_raise(FiberError, '[ruby-core:23651]') {f.transfer} + f = Fiber.new {f.resume 1} + assert_equal(1, f.transfer) end def test_fiber_transfer_segv @@ -289,14 +289,12 @@ class TestFiber < Test::Unit::TestCase assert_raise(FiberError){ g=nil f=Fiber.new{ - g.resume - g.resume + g.transfer } g=Fiber.new{ f.resume - f.resume } - f.transfer + f.resume } end |