From b56d4e570a60a8e84df8288c3122eb5bb5c20af6 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 14 Mar 2019 15:30:54 -0300 Subject: Changes in the warning system - The warning functions get an extra parameter that tells whether message is to be continued (instead of using end-of-lines as a signal). - The user data for the warning function is a regular value, instead of a writable slot inside the Lua state. --- testes/all.lua | 10 +++++----- testes/api.lua | 12 +++++------- testes/gc.lua | 11 +++++++---- 3 files changed, 17 insertions(+), 16 deletions(-) (limited to 'testes') diff --git a/testes/all.lua b/testes/all.lua index 506afad2..8d727b6b 100644 --- a/testes/all.lua +++ b/testes/all.lua @@ -6,7 +6,7 @@ local version = "Lua 5.4" if _VERSION ~= version then warn(string.format( - "This test suite is for %s, not for %s\nExiting tests\n", version, _VERSION)) + "This test suite is for %s, not for %s\nExiting tests", version, _VERSION)) return end @@ -190,16 +190,16 @@ assert(dofile('verybig.lua', true) == 10); collectgarbage() dofile('files.lua') if #msgs > 0 then - warn("#tests not performed:\n ") + warn("#tests not performed:", true) for i=1,#msgs do - warn(msgs[i]); warn("\n ") + warn("\n ", true); warn(msgs[i], true) end warn("\n") end print("(there should be two warnings now)") -warn("#This is "); warn("an expected"); warn(" warning\n") -warn("#This is"); warn(" another one\n") +warn("#This is ", true); warn("an expected", true); warn(" warning") +warn("#This is", true); warn(" another one") -- no test module should define 'debug' assert(debug == nil) diff --git a/testes/api.lua b/testes/api.lua index d034ea80..08672e8a 100644 --- a/testes/api.lua +++ b/testes/api.lua @@ -114,13 +114,11 @@ end -- testing warnings T.testC([[ - warning "#This shold be a" - warning " single " - warning "warning -" - warning "#This should be " - warning "another one -" + warningC "#This shold be a" + warningC " single " + warning "warning" + warningC "#This should be " + warning "another one" ]]) diff --git a/testes/gc.lua b/testes/gc.lua index 05bf564e..91e78a48 100644 --- a/testes/gc.lua +++ b/testes/gc.lua @@ -18,6 +18,8 @@ assert(collectgarbage("incremental") == "generational") assert(collectgarbage("incremental") == "incremental") +local function nop () end + local function gcinfo () return collectgarbage"count" * 1024 end @@ -388,7 +390,7 @@ if T then collectgarbage() for i = 1, 10 do assert(s[i]) end - getmetatable(u).__gc = false + getmetatable(u).__gc = nil end print '+' @@ -604,8 +606,8 @@ if T then collectgarbage("stop") local x = T.newuserdata(0) local y = T.newuserdata(0) - debug.setmetatable(y, {__gc = true}) -- bless the new udata before... - debug.setmetatable(x, {__gc = true}) -- ...the old one + debug.setmetatable(y, {__gc = nop}) -- bless the new udata before... + debug.setmetatable(x, {__gc = nop}) -- ...the old one assert(T.gccolor(y) == "white") T.checkmemory() collectgarbage("restart") @@ -631,6 +633,7 @@ if T then assert(T.totalmem("thread") == t + 1) end + -- create an object to be collected when state is closed do local setmetatable,assert,type,print,getmetatable = @@ -650,7 +653,7 @@ end -- create several objects to raise errors when collected while closing state if T then - local error, assert, warn, find = error, assert, warn, string.find + local error, assert, find = error, assert, string.find local n = 0 local lastmsg local mt = {__gc = function (o) -- cgit v1.2.3-55-g6feb