mirror of
https://github.com/ruby/ruby.git
synced 2025-09-16 00:54:01 +02:00
[Bug #20978] Stringize Fiber storage keys
This commit is contained in:
parent
a11bb36316
commit
adad97a031
Notes:
git
2024-12-23 11:13:09 +00:00
3 changed files with 25 additions and 2 deletions
|
@ -90,7 +90,9 @@ ruby_version_is "3.2" do
|
|||
key = :"#{self.class.name}#.#{self.object_id}"
|
||||
Fiber.new { Fiber[key] = 42; Fiber[key] }.resume.should == 42
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "3.2.3"..."3.4" do
|
||||
it "can't use invalid keys" do
|
||||
invalid_keys = [Object.new, "Foo", 12]
|
||||
invalid_keys.each do |key|
|
||||
|
@ -99,6 +101,15 @@ ruby_version_is "3.2" do
|
|||
end
|
||||
end
|
||||
|
||||
ruby_version_is "3.4" do
|
||||
it "can use keys as strings" do
|
||||
key = Object.new
|
||||
def key.to_str; "Foo"; end
|
||||
Fiber[key] = 42
|
||||
Fiber["Foo"].should == 42
|
||||
end
|
||||
end
|
||||
|
||||
it "can access the storage of the parent fiber" do
|
||||
f = Fiber.new(storage: {life: 42}) do
|
||||
Fiber.new { Fiber[:life] }.resume
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue