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 authored and eregon committed Aug 28, 2023
1 parent e538824 commit 83c1550
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 @@ -90,6 +90,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 == 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 83c1550

Please sign in to comment.