diff options
author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2023-08-24 15:19:33 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-24 15:19:33 +1200 |
commit | d4c720a91bc7bb9ff31810e1720acffb939f7a2f (patch) | |
tree | 164045fc674af9c849d76ab446cfd3caece7fee3 /spec | |
parent | bd22bb259c183b91656bea72899fe91c31aeb44e (diff) | |
download | ruby-d4c720a91bc7bb9ff31810e1720acffb939f7a2f.tar.gz |
Fix support for dynamic keys. (#8273)
* Skip RBS test.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/ruby/core/fiber/storage_spec.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/ruby/core/fiber/storage_spec.rb b/spec/ruby/core/fiber/storage_spec.rb index e99fe6e4df..e5232c8894 100644 --- a/spec/ruby/core/fiber/storage_spec.rb +++ b/spec/ruby/core/fiber/storage_spec.rb @@ -74,6 +74,20 @@ describe "Fiber.[]" do Fiber.new { Fiber[:life] }.resume.should be_nil end end + + ruby_version_is "3.2.3" do + it "can use dynamically defined keys" do + key = :"#{self.class.name}#.#{self.object_id}" + Fiber.new { Fiber[key] = 42; Fiber[key] }.resume.should == 42 + end + + it "can't use invalid keys" do + invalid_keys = [Object.new, "Foo", 12] + invalid_keys.each do |key| + -> { Fiber[key] }.should raise_error(TypeError) + end + end + end end describe "Fiber.[]=" do |