aboutsummaryrefslogtreecommitdiff
path: root/testes
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-03-14 15:30:54 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-03-14 15:30:54 -0300
commitb56d4e570a60a8e84df8288c3122eb5bb5c20af6 (patch)
treed5597a7865712fc407adbb41fe0749e728617ca7 /testes
parent9eca305e75010e30342486a4139846faf1b3eccb (diff)
downloadlua-b56d4e570a60a8e84df8288c3122eb5bb5c20af6.tar.gz
lua-b56d4e570a60a8e84df8288c3122eb5bb5c20af6.tar.bz2
lua-b56d4e570a60a8e84df8288c3122eb5bb5c20af6.zip
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.
Diffstat (limited to 'testes')
-rw-r--r--testes/all.lua10
-rw-r--r--testes/api.lua12
-rw-r--r--testes/gc.lua11
3 files changed, 17 insertions, 16 deletions
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 @@
6local version = "Lua 5.4" 6local version = "Lua 5.4"
7if _VERSION ~= version then 7if _VERSION ~= version then
8 warn(string.format( 8 warn(string.format(
9 "This test suite is for %s, not for %s\nExiting tests\n", version, _VERSION)) 9 "This test suite is for %s, not for %s\nExiting tests", version, _VERSION))
10 return 10 return
11end 11end
12 12
@@ -190,16 +190,16 @@ assert(dofile('verybig.lua', true) == 10); collectgarbage()
190dofile('files.lua') 190dofile('files.lua')
191 191
192if #msgs > 0 then 192if #msgs > 0 then
193 warn("#tests not performed:\n ") 193 warn("#tests not performed:", true)
194 for i=1,#msgs do 194 for i=1,#msgs do
195 warn(msgs[i]); warn("\n ") 195 warn("\n ", true); warn(msgs[i], true)
196 end 196 end
197 warn("\n") 197 warn("\n")
198end 198end
199 199
200print("(there should be two warnings now)") 200print("(there should be two warnings now)")
201warn("#This is "); warn("an expected"); warn(" warning\n") 201warn("#This is ", true); warn("an expected", true); warn(" warning")
202warn("#This is"); warn(" another one\n") 202warn("#This is", true); warn(" another one")
203 203
204-- no test module should define 'debug' 204-- no test module should define 'debug'
205assert(debug == nil) 205assert(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
114 114
115-- testing warnings 115-- testing warnings
116T.testC([[ 116T.testC([[
117 warning "#This shold be a" 117 warningC "#This shold be a"
118 warning " single " 118 warningC " single "
119 warning "warning 119 warning "warning"
120" 120 warningC "#This should be "
121 warning "#This should be " 121 warning "another one"
122 warning "another one
123"
124]]) 122]])
125 123
126 124
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")
18assert(collectgarbage("incremental") == "incremental") 18assert(collectgarbage("incremental") == "incremental")
19 19
20 20
21local function nop () end
22
21local function gcinfo () 23local function gcinfo ()
22 return collectgarbage"count" * 1024 24 return collectgarbage"count" * 1024
23end 25end
@@ -388,7 +390,7 @@ if T then
388 collectgarbage() 390 collectgarbage()
389 for i = 1, 10 do assert(s[i]) end 391 for i = 1, 10 do assert(s[i]) end
390 392
391 getmetatable(u).__gc = false 393 getmetatable(u).__gc = nil
392 394
393end 395end
394print '+' 396print '+'
@@ -604,8 +606,8 @@ if T then
604 collectgarbage("stop") 606 collectgarbage("stop")
605 local x = T.newuserdata(0) 607 local x = T.newuserdata(0)
606 local y = T.newuserdata(0) 608 local y = T.newuserdata(0)
607 debug.setmetatable(y, {__gc = true}) -- bless the new udata before... 609 debug.setmetatable(y, {__gc = nop}) -- bless the new udata before...
608 debug.setmetatable(x, {__gc = true}) -- ...the old one 610 debug.setmetatable(x, {__gc = nop}) -- ...the old one
609 assert(T.gccolor(y) == "white") 611 assert(T.gccolor(y) == "white")
610 T.checkmemory() 612 T.checkmemory()
611 collectgarbage("restart") 613 collectgarbage("restart")
@@ -631,6 +633,7 @@ if T then
631 assert(T.totalmem("thread") == t + 1) 633 assert(T.totalmem("thread") == t + 1)
632end 634end
633 635
636
634-- create an object to be collected when state is closed 637-- create an object to be collected when state is closed
635do 638do
636 local setmetatable,assert,type,print,getmetatable = 639 local setmetatable,assert,type,print,getmetatable =
@@ -650,7 +653,7 @@ end
650 653
651-- create several objects to raise errors when collected while closing state 654-- create several objects to raise errors when collected while closing state
652if T then 655if T then
653 local error, assert, warn, find = error, assert, warn, string.find 656 local error, assert, find = error, assert, string.find
654 local n = 0 657 local n = 0
655 local lastmsg 658 local lastmsg
656 local mt = {__gc = function (o) 659 local mt = {__gc = function (o)