[前][次][番号順一覧][スレッド一覧]

ruby-changes:58386

From: Koichi <ko1@a...>
Date: Thu, 24 Oct 2019 16:53:14 +0900 (JST)
Subject: [ruby-changes:58386] 4c3e3b8028 (master): Revert "Fix Fiber#transfer"

https://git.ruby-lang.org/ruby.git/commit/?id=4c3e3b8028

From 4c3e3b8028ca76fcaedc0e40d9ac678e3ac79ee9 Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Thu, 24 Oct 2019 15:03:26 +0900
Subject: Revert "Fix Fiber#transfer"

This reverts commit fa8ac91e957a076f6df1adaecad7896817138009.

Previous behavior is intentional.

diff --git a/cont.c b/cont.c
index 8e1dc6d..61f42b3 100644
--- a/cont.c
+++ b/cont.c
@@ -2226,8 +2226,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/cont.c#L2226
 rb_fiber_m_transfer(int argc, VALUE *argv, VALUE fiber_value)
 {
     rb_fiber_t *fiber = fiber_ptr(fiber_value);
-    fiber_current()->transferred = 1;
-    fiber->transferred = 0;
+    fiber->transferred = 1;
     return fiber_switch(fiber, argc, argv, 0, PASS_KW_SPLAT);
 }
 
diff --git a/spec/ruby/library/fiber/transfer_spec.rb b/spec/ruby/library/fiber/transfer_spec.rb
index fa094a0..d130536 100644
--- a/spec/ruby/library/fiber/transfer_spec.rb
+++ b/spec/ruby/library/fiber/transfer_spec.rb
@@ -42,18 +42,9 @@ describe "Fiber#transfer" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/library/fiber/transfer_spec.rb#L42
     fiber2.transfer.should == [:fiber2_start, :fiber1, :fiber2_end]
   end
 
-  ruby_version_is ''...'2.7' do
-    it "raises a FiberError when transferring to a Fiber which resumes itself" do
-      fiber = Fiber.new { fiber.resume }
-      -> { fiber.transfer }.should raise_error(FiberError)
-    end
-  end
-
-  ruby_version_is '2.7' do
-    it "allows transferring to a Fiber which resumes itself" do
-      fiber = Fiber.new { fiber.resume 1 }
-      fiber.transfer.should == 1
-    end
+  it "raises a FiberError when transferring to a Fiber which resumes itself" do
+    fiber = Fiber.new { fiber.resume }
+    -> { fiber.transfer }.should raise_error(FiberError)
   end
 
   it "works if Fibers in different Threads each transfer to a Fiber in the same Thread" do
diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb
index aa47aaf..2d7cbc8 100644
--- a/test/ruby/test_fiber.rb
+++ b/test/ruby/test_fiber.rb
@@ -222,8 +222,8 @@ class TestFiber < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_fiber.rb#L222
   end
 
   def test_resume_self
-    f = Fiber.new {f.resume 1}
-    assert_equal(1, f.transfer)
+    f = Fiber.new {f.resume}
+    assert_raise(FiberError, '[ruby-core:23651]') {f.transfer}
   end
 
   def test_fiber_transfer_segv
@@ -289,12 +289,14 @@ class TestFiber < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_fiber.rb#L289
     assert_raise(FiberError){
       g=nil
       f=Fiber.new{
-        g.transfer
+        g.resume
+        g.resume
       }
       g=Fiber.new{
         f.resume
+        f.resume
       }
-      f.resume
+      f.transfer
     }
   end
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]