diff options
Diffstat (limited to '')
-rw-r--r-- | testes/all.lua | 2 | ||||
-rw-r--r-- | testes/coroutine.lua | 19 | ||||
-rw-r--r-- | testes/errors.lua | 4 | ||||
-rw-r--r-- | testes/gc.lua | 10 |
4 files changed, 34 insertions, 1 deletions
diff --git a/testes/all.lua b/testes/all.lua index 5df0ff9b..413d4da2 100644 --- a/testes/all.lua +++ b/testes/all.lua | |||
@@ -287,7 +287,7 @@ print("final OK !!!") | |||
287 | 287 | ||
288 | --[[ | 288 | --[[ |
289 | ***************************************************************************** | 289 | ***************************************************************************** |
290 | * Copyright (C) 1994-2016 Lua.org, PUC-Rio. | 290 | * Copyright (C) 1994-2025 Lua.org, PUC-Rio. |
291 | * | 291 | * |
292 | * Permission is hereby granted, free of charge, to any person obtaining | 292 | * Permission is hereby granted, free of charge, to any person obtaining |
293 | * a copy of this software and associated documentation files (the | 293 | * a copy of this software and associated documentation files (the |
diff --git a/testes/coroutine.lua b/testes/coroutine.lua index e566c86e..03e04451 100644 --- a/testes/coroutine.lua +++ b/testes/coroutine.lua | |||
@@ -493,6 +493,25 @@ assert(not pcall(a, a)) | |||
493 | a = nil | 493 | a = nil |
494 | 494 | ||
495 | 495 | ||
496 | do | ||
497 | -- bug in 5.4: thread can use message handler higher in the stack | ||
498 | -- than the variable being closed | ||
499 | local c = coroutine.create(function() | ||
500 | local clo <close> = setmetatable({}, {__close=function() | ||
501 | local x = 134 -- will overwrite message handler | ||
502 | error(x) | ||
503 | end}) | ||
504 | -- yields coroutine but leaves a new message handler for it, | ||
505 | -- that would be used when closing the coroutine (except that it | ||
506 | -- will be overwritten) | ||
507 | xpcall(coroutine.yield, function() return "XXX" end) | ||
508 | end) | ||
509 | |||
510 | assert(coroutine.resume(c)) -- start coroutine | ||
511 | local st, msg = coroutine.close(c) | ||
512 | assert(not st and msg == 134) | ||
513 | end | ||
514 | |||
496 | -- access to locals of erroneous coroutines | 515 | -- access to locals of erroneous coroutines |
497 | local x = coroutine.create (function () | 516 | local x = coroutine.create (function () |
498 | local a = 10 | 517 | local a = 10 |
diff --git a/testes/errors.lua b/testes/errors.lua index 80d91a92..15401b4f 100644 --- a/testes/errors.lua +++ b/testes/errors.lua | |||
@@ -137,6 +137,10 @@ checkmessage("aaa=(1)..{}", "a table value") | |||
137 | -- bug in 5.4.6 | 137 | -- bug in 5.4.6 |
138 | checkmessage("a = {_ENV = {}}; print(a._ENV.x + 1)", "field 'x'") | 138 | checkmessage("a = {_ENV = {}}; print(a._ENV.x + 1)", "field 'x'") |
139 | 139 | ||
140 | -- a similar bug in 5.4.7, since 5.4.0 | ||
141 | checkmessage("print(('_ENV').x + 1)", "field 'x'") | ||
142 | |||
143 | |||
140 | _G.aaa, _G.bbbb = nil | 144 | _G.aaa, _G.bbbb = nil |
141 | 145 | ||
142 | -- calls | 146 | -- calls |
diff --git a/testes/gc.lua b/testes/gc.lua index 03093e34..f017f330 100644 --- a/testes/gc.lua +++ b/testes/gc.lua | |||
@@ -301,6 +301,16 @@ collectgarbage() | |||
301 | assert(next(a) == string.rep('$', 11)) | 301 | assert(next(a) == string.rep('$', 11)) |
302 | 302 | ||
303 | 303 | ||
304 | if T then -- bug since 5.3: all-weak tables are not being revisited | ||
305 | T.gcstate("propagate") | ||
306 | local t = setmetatable({}, {__mode = "kv"}) | ||
307 | T.gcstate("atomic") -- 't' was visited | ||
308 | setmetatable(t, {__mode = "kv"}) | ||
309 | T.gcstate("pause") -- its new metatable is not being visited | ||
310 | assert(getmetatable(t).__mode == "kv") | ||
311 | end | ||
312 | |||
313 | |||
304 | -- 'bug' in 5.1 | 314 | -- 'bug' in 5.1 |
305 | a = {} | 315 | a = {} |
306 | local t = {x = 10} | 316 | local t = {x = 10} |