Skip to content

Commit

Permalink
Fix Node#to_s(io) method
Browse files Browse the repository at this point in the history
  • Loading branch information
petoem committed May 31, 2018
1 parent a1e746f commit 24db349
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions spec/a-star_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,14 @@ describe AStar do
end
path.should eq([a, b, c, d, e])
end

it "Node#to_s(io) appends correct data" do
io = IO::Memory.new
AStar::Node.new("Spec").to_s io
io.to_s.should eq("Spec")

io.clear
AStar::Node.new({spec: true}).to_s io
io.to_s.should eq("{spec: true}")
end
end
3 changes: 2 additions & 1 deletion src/a-star.cr
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ module AStar
self
end

# Appends `#data` to the given IO object.
def to_s(io : IO) : Nil
io << @name
io << @data
end
end
end

0 comments on commit 24db349

Please sign in to comment.