mirror of
https://github.com/lua/lua
synced 2026-09-29 04:35:58 +03:00
Added a warning system to Lua
The warning system is just a way for Lua to emit warnings, messages to the programmer that do not interfere with the running program.
This commit is contained in:
parent
ba7da13ec5
commit
437a5b07d4
10 changed files with 173 additions and 15 deletions
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
local version = "Lua 5.4"
|
||||
if _VERSION ~= version then
|
||||
io.stderr:write("\nThis test suite is for ", version, ", not for ", _VERSION,
|
||||
"\nExiting tests\n")
|
||||
warn(string.format(
|
||||
"This test suite is for %s, not for %s\nExiting tests\n", version, _VERSION))
|
||||
return
|
||||
end
|
||||
|
||||
|
|
@ -190,11 +190,10 @@ assert(dofile('verybig.lua', true) == 10); collectgarbage()
|
|||
dofile('files.lua')
|
||||
|
||||
if #msgs > 0 then
|
||||
print("\ntests not performed:")
|
||||
warn("*tests not performed:\n ")
|
||||
for i=1,#msgs do
|
||||
print(msgs[i])
|
||||
warn(msgs[i]); warn("\n ")
|
||||
end
|
||||
print()
|
||||
end
|
||||
|
||||
-- no test module should define 'debug'
|
||||
|
|
@ -220,6 +219,10 @@ local _G, showmem, print, format, clock, time, difftime, assert, open =
|
|||
local fname = T and "time-debug.txt" or "time.txt"
|
||||
local lasttime
|
||||
|
||||
|
||||
warn("*This is "); warn("an expected"); warn(" warning\n")
|
||||
warn("*This is"); warn(" another one\n")
|
||||
|
||||
if not usertests then
|
||||
-- open file with time of last performed test
|
||||
local f = io.open(fname)
|
||||
|
|
|
|||
|
|
@ -111,6 +111,20 @@ do -- testing 'rotate'
|
|||
tcheck(t, {10, 20, 30, 40})
|
||||
end
|
||||
|
||||
|
||||
-- testing warnings
|
||||
T.testC([[
|
||||
warning "*This "
|
||||
warning "warning "
|
||||
warning "should be in a"
|
||||
warning " single line
|
||||
"
|
||||
warning "*This should be "
|
||||
warning "another warning
|
||||
"
|
||||
]])
|
||||
|
||||
|
||||
-- testing message handlers
|
||||
do
|
||||
local f = T.makeCfunc[[
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue