Skip to content

Commit

Permalink
Messages not being formatted with the correct values
Browse files Browse the repository at this point in the history
Fix an issue with format_message not reporting the correct error values.
  • Loading branch information
cpeosphoros committed Aug 5, 2017
1 parent c80b928 commit 10cd74a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions telescope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,15 @@ local function make_assertion(name, message, func)
local a = {}
local args = {...}
local nargs = select('#', ...)
if nargs > num_vars then
if nargs > num_vars then
local userErrorMessage = args[num_vars+1]
if type(userErrorMessage) == "string" then
return(assertion_message_prefix .. userErrorMessage)
else
error(string.format('assert_%s expected %d arguments but got %d', name, num_vars, #args))
end
end
for i = 1, nargs do a[i] = tostring(v) end
for i = 1, nargs do a[i] = tostring(args[i]) end
for i = nargs+1, num_vars do a[i] = 'nil' end
return (assertion_message_prefix .. message):format(unpack(a))
end
Expand Down Expand Up @@ -443,12 +443,12 @@ local function run(contexts, callbacks, test_filter)
table.sort(ancestors)
-- this "before" is the test callback passed into the runner
invoke_callback("before", result)

-- run all the "before" blocks/functions
for _, a in ipairs(ancestors) do
if contexts[a].before then
if contexts[a].before then
setfenv(contexts[a].before, env)
contexts[a].before()
contexts[a].before()
end
end

Expand All @@ -465,9 +465,9 @@ local function run(contexts, callbacks, test_filter)
-- Run all the "after" blocks/functions
table.reverse(ancestors)
for _, a in ipairs(ancestors) do
if contexts[a].after then
if contexts[a].after then
setfenv(contexts[a].after, env)
contexts[a].after()
contexts[a].after()
end
end

Expand Down

0 comments on commit 10cd74a

Please sign in to comment.