Skip to content

Commit

Permalink
Expand tests of Fiber.[]
Browse files Browse the repository at this point in the history
* It can access storage of the parent fiber
* It cannot access storage with non-symbol keys
  • Loading branch information
herwinw committed Aug 27, 2023
1 parent fa4c9f4 commit 887e4d0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core/fiber/storage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@
it "returns nil if the current fiber has no storage" do
Fiber.new { Fiber[:life] }.resume.should be_nil
end

it "can access the storage of the parent fiber" do
f = Fiber.new(storage: {life: 42}) do
Fiber.new { Fiber[:life] }.resume
end
f.resume.should == {life: 42}
end

it "can't access the storage of the fiber with non-symbol keys" do
-> { Fiber[Object.new] }.should raise_error(TypeError)
end
end
end

Expand Down

0 comments on commit 887e4d0

Please sign in to comment.