Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

Commit

Permalink
Warn tostring (#171) (#195)
Browse files Browse the repository at this point in the history
* Add NumberRange (#155)

* Tostring warn arguments

* Remove NumberRange from another pr

* Revert "Remove NumberRange from another pr"

This reverts commit 6a9d046.

* Removed the wrong thing
  • Loading branch information
jacobselbo authored and LPGhatguy committed Jul 11, 2019
1 parent 900c8c3 commit 5e00641
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/functions/warn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local function warn(...)
local count = select("#", ...)
for i = 1, count do
local piece = select(i, ...)
io.stderr:write(piece)
io.stderr:write(tostring(piece))

if i < count then
io.stderr:write("\t")
Expand Down
14 changes: 14 additions & 0 deletions lib/functions/warn_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,18 @@ describe("functions.warn", function()
assert.spy(writeSpy).was.called(4) -- IT'S DOGE, \t, AAH!, \n
io.stderr = oldErr -- luacheck: ignore
end)

it("should warn with a non-string argument", function()
local oldErr, writeSpy = setupWarnDetour()
warn(1)
assert.spy(writeSpy).was_called_with(io.stderr, "1")
io.stderr = oldErr -- luacheck: ignore
end)

it("should warn with non-string arguments", function()
local oldErr, writeSpy = setupWarnDetour()
warn(2, 3)
assert.spy(writeSpy).was.called(4) -- 2, \t, 3, \n
io.stderr = oldErr -- luacheck: ignore
end)
end)

0 comments on commit 5e00641

Please sign in to comment.