assert_equal('./test/test_assert-gooder.lua:'..curline(-3)..': '..'assertion failed! bad argument #1 \'a\' to the anonymous function at ./test/test_assert-gooder.lua:'..curline(-4)..' (string expected, but got number: 2)',msg)
SUITE:addTest('argument to named function',function()
localf=function(a)
assert(type(a)=='string')
end
local_,msg=pcall(function()f(2)end)
assert_equal('./test/test_assert-gooder.lua:'..curline(-3)..': '..'assertion failed! bad argument #1 \'a\' to \'f\' (string expected, but got number: 2)',msg)
assert_equal('./test/test_assert-gooder.lua:'..curline(-2)..': '..'assertion failed! bad key "b" in local \'a\' (string expected, but got number: 39)',msg)
end)
SUITE:addTest('subscript constant',function()
local_,msg=pcall(function()
locala={4,2,3,6}
assert(type(a.b)=='string')
end)
assert_equal('./test/test_assert-gooder.lua:'..curline(-2)..': '..'assertion failed! bad key 2 in local \'a\' (string expected, but got number: 2)',msg)
end)
SUITE:addTest('subscript variable',function()
local_,msg=pcall(function()
locala,i={4,2,3,6},2
assert(type(a.b)=='string')
end)
assert_equal('./test/test_assert-gooder.lua:'..curline(-2)..': '..'assertion failed! bad key 2 in local \'a\' (string expected, but got number: 2)',msg)
assert_equal('[string "return function(a) assert(type(a) == \'string\'..."]:1: '..'assertion failed! bad argument #1 \'a\' to the anonymous function from loaded string (string expected, but got number: 42)',msg)
assert_equal('./test/test_assert-gooder.lua:'..curline(-3)..': '..'assertion failed! this assert will always fail, as it\'s body is `false`. assumingly this should be an unreachable part of \'f\'',msg)
end)
SUITE:addTest('constant nil',function()
local_,msg=pcall(function()
assert(nil)
end)
assert_equal('./test/test_assert-gooder.lua:'..curline(-2)..': '..'assertion failed! this assert will always fail, as it\'s body is `nil`. assumingly this should be an unreachable part of the anonymous function at ./test/test_assert-gooder.lua:'..curline(-3),msg)