summaryrefslogtreecommitdiff
path: root/test/ruby/test_fiber.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2024-12-23 18:16:28 +0900
committerNobuyoshi Nakada <[email protected]>2024-12-23 18:16:28 +0900
commitadad97a0310ebcd749e906be48bdabe9740deddf (patch)
treecb3a049226500302712f2551bb22bfa5a5dfbee5 /test/ruby/test_fiber.rb
parenta11bb36316fa4e2a63e58ca03c44dca7ad93a32f (diff)
[Bug #20978] Stringize Fiber storage keys
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12438
Diffstat (limited to 'test/ruby/test_fiber.rb')
-rw-r--r--test/ruby/test_fiber.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb
index 45e5d12092..19cd52f7c8 100644
--- a/test/ruby/test_fiber.rb
+++ b/test/ruby/test_fiber.rb
@@ -252,6 +252,18 @@ class TestFiber < Test::Unit::TestCase
assert_equal(nil, Thread.current[:v]);
end
+ def test_fiber_variables
+ assert_equal "bar", Fiber.new {Fiber[:foo] = "bar"; Fiber[:foo]}.resume
+
+ key = :"#{self.class.name}#.#{self.object_id}"
+ Fiber[key] = 42
+ assert_equal 42, Fiber[key]
+
+ key = Object.new
+ def key.to_str; "foo"; end
+ assert_equal "Bar", Fiber.new {Fiber[key] = "Bar"; Fiber[key]}.resume
+ end
+
def test_alive
fib = Fiber.new{Fiber.yield}
assert_equal(true, fib.alive?)