From 437a5b07d415e1a74160ddfd804017171d6cc5cb Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 28 Dec 2018 15:42:34 -0200 Subject: 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. --- testes/all.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'testes/all.lua') diff --git a/testes/all.lua b/testes/all.lua index 84ba80a6..bde4195e 100644 --- a/testes/all.lua +++ b/testes/all.lua @@ -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) -- cgit v1.2.3-55-g6feb