diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-08-20 13:42:26 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-08-20 13:42:26 -0300 |
commit | be78aeae4c429d7d68af3a3e1b0cf8e52fcff160 (patch) | |
tree | e81d25014e238f589997f109ba10a875c3a875dc /testes | |
parent | 5bc47fe83087e0686f4639d031801837846e4c65 (diff) | |
download | lua-be78aeae4c429d7d68af3a3e1b0cf8e52fcff160.tar.gz lua-be78aeae4c429d7d68af3a3e1b0cf8e52fcff160.tar.bz2 lua-be78aeae4c429d7d68af3a3e1b0cf8e52fcff160.zip |
Default for warnings changed to "off"
Warnings are mostly a tool to help developers (e.g., by showing hidden
error messages); regular users usually don't need to see them.
Diffstat (limited to 'testes')
-rw-r--r-- | testes/all.lua | 5 | ||||
-rw-r--r-- | testes/coroutine.lua | 1 | ||||
-rw-r--r-- | testes/gc.lua | 2 | ||||
-rw-r--r-- | testes/locals.lua | 1 | ||||
-rw-r--r-- | testes/main.lua | 11 |
5 files changed, 13 insertions, 7 deletions
diff --git a/testes/all.lua b/testes/all.lua index 42809b9a..db074dd8 100644 --- a/testes/all.lua +++ b/testes/all.lua | |||
@@ -5,8 +5,8 @@ | |||
5 | 5 | ||
6 | local version = "Lua 5.4" | 6 | local version = "Lua 5.4" |
7 | if _VERSION ~= version then | 7 | if _VERSION ~= version then |
8 | warn("This test suite is for ", version, | 8 | io.stderr:write("This test suite is for ", version, |
9 | ", not for ", _VERSION, "\nExiting tests") | 9 | ", not for ", _VERSION, "\nExiting tests") |
10 | return | 10 | return |
11 | end | 11 | end |
12 | 12 | ||
@@ -210,6 +210,7 @@ if #msgs > 0 then | |||
210 | end | 210 | end |
211 | 211 | ||
212 | print("(there should be two warnings now)") | 212 | print("(there should be two warnings now)") |
213 | warn("@on") | ||
213 | warn("#This is ", "an expected", " warning") | 214 | warn("#This is ", "an expected", " warning") |
214 | warn("@off") | 215 | warn("@off") |
215 | warn("******** THIS WARNING SHOULD NOT APPEAR **********") | 216 | warn("******** THIS WARNING SHOULD NOT APPEAR **********") |
diff --git a/testes/coroutine.lua b/testes/coroutine.lua index 4fc23261..79bbf2ea 100644 --- a/testes/coroutine.lua +++ b/testes/coroutine.lua | |||
@@ -163,6 +163,7 @@ do | |||
163 | assert(not X and coroutine.status(co) == "dead") | 163 | assert(not X and coroutine.status(co) == "dead") |
164 | 164 | ||
165 | -- error closing a coroutine | 165 | -- error closing a coroutine |
166 | warn("@on") | ||
166 | local x = 0 | 167 | local x = 0 |
167 | co = coroutine.create(function() | 168 | co = coroutine.create(function() |
168 | local y <close> = func2close(function (self,err) | 169 | local y <close> = func2close(function (self,err) |
diff --git a/testes/gc.lua b/testes/gc.lua index 34854d6f..bb4e3493 100644 --- a/testes/gc.lua +++ b/testes/gc.lua | |||
@@ -369,7 +369,7 @@ if T then | |||
369 | s[n] = i | 369 | s[n] = i |
370 | end | 370 | end |
371 | 371 | ||
372 | warn("@store") | 372 | warn("@on"); warn("@store") |
373 | collectgarbage() | 373 | collectgarbage() |
374 | assert(string.find(_WARN, "error in __gc metamethod")) | 374 | assert(string.find(_WARN, "error in __gc metamethod")) |
375 | assert(string.match(_WARN, "@(.-)@") == "expected"); _WARN = nil | 375 | assert(string.match(_WARN, "@(.-)@") == "expected"); _WARN = nil |
diff --git a/testes/locals.lua b/testes/locals.lua index b4de523d..58ad18cc 100644 --- a/testes/locals.lua +++ b/testes/locals.lua | |||
@@ -313,6 +313,7 @@ local function checkwarn (msg) | |||
313 | end | 313 | end |
314 | end | 314 | end |
315 | 315 | ||
316 | warn("@on") | ||
316 | 317 | ||
317 | do print("testing errors in __close") | 318 | do print("testing errors in __close") |
318 | 319 | ||
diff --git a/testes/main.lua b/testes/main.lua index 5d2652cb..de14a088 100644 --- a/testes/main.lua +++ b/testes/main.lua | |||
@@ -221,8 +221,11 @@ assert(string.find(getoutput(), "error calling 'print'")) | |||
221 | RUN('echo "io.stderr:write(1000)\ncont" | lua -e "require\'debug\'.debug()" 2> %s', out) | 221 | RUN('echo "io.stderr:write(1000)\ncont" | lua -e "require\'debug\'.debug()" 2> %s', out) |
222 | checkout("lua_debug> 1000lua_debug> ") | 222 | checkout("lua_debug> 1000lua_debug> ") |
223 | 223 | ||
224 | -- test warnings | 224 | |
225 | RUN('echo "io.stderr:write(1); warn[[XXX]]" | lua -q 2> %s', out) | 225 | print("testing warnings") |
226 | |||
227 | -- no warnings by default | ||
228 | RUN('echo "io.stderr:write(1); warn[[XXX]]" | lua 2> %s', out) | ||
226 | checkout("1") | 229 | checkout("1") |
227 | 230 | ||
228 | prepfile[[ | 231 | prepfile[[ |
@@ -236,7 +239,7 @@ warn("", "@on") -- again, no control, real warning | |||
236 | warn("@on") -- keep it "started" | 239 | warn("@on") -- keep it "started" |
237 | warn("Z", "Z", "Z") -- common warning | 240 | warn("Z", "Z", "Z") -- common warning |
238 | ]] | 241 | ]] |
239 | RUN('lua %s 2> %s', prog, out) | 242 | RUN('lua -W %s 2> %s', prog, out) |
240 | checkout[[ | 243 | checkout[[ |
241 | Lua warning: @offXXX@off | 244 | Lua warning: @offXXX@off |
242 | Lua warning: @on | 245 | Lua warning: @on |
@@ -250,7 +253,7 @@ warn("@allow") | |||
250 | u1 = setmetatable({}, {__gc = function () error("XYZ") end}) | 253 | u1 = setmetatable({}, {__gc = function () error("XYZ") end}) |
251 | u2 = setmetatable({}, {__gc = function () error("ZYX") end}) | 254 | u2 = setmetatable({}, {__gc = function () error("ZYX") end}) |
252 | ]] | 255 | ]] |
253 | RUN('lua %s 2> %s', prog, out) | 256 | RUN('lua -W %s 2> %s', prog, out) |
254 | checkprogout("ZYX)\nXYZ)\n") | 257 | checkprogout("ZYX)\nXYZ)\n") |
255 | 258 | ||
256 | 259 | ||