summaryrefslogtreecommitdiff
path: root/test/fiber
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2022-12-20 18:21:43 +0100
committerBenoit Daloze <eregontp@gmail.com>2022-12-20 19:32:23 +0100
commit0efa36ac06a14a3e2e0aca395fee6530c790bdf1 (patch)
treeea1b27a60f59fa7ce9e6f3efe5fd9934366c6f15 /test/fiber
parentd557f17974384dde4ff2da021a1b38905a39bda2 (diff)
Ensure Fiber storage is only accessed from the Fiber it belongs to
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6972
Diffstat (limited to 'test/fiber')
-rw-r--r--test/fiber/test_storage.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/fiber/test_storage.rb b/test/fiber/test_storage.rb
index 6e75b71347..3726decbdb 100644
--- a/test/fiber/test_storage.rb
+++ b/test/fiber/test_storage.rb
@@ -41,6 +41,18 @@ class TestFiberStorage < Test::Unit::TestCase
Warning[:experimental] = old
end
+ def test_storage_only_allow_access_from_same_fiber
+ old, Warning[:experimental] = Warning[:experimental], false
+
+ f = Fiber.new do
+ Fiber[:a] = 1
+ end
+ assert_raise(ArgumentError) { f.storage }
+ assert_raise(ArgumentError) { f.storage = {} }
+ ensure
+ Warning[:experimental] = old
+ end
+
def test_inherited_storage
Fiber.new(storage: {foo: :bar}) do
f = Fiber.new do