diff options
Diffstat (limited to 'testes/locals.lua')
-rw-r--r-- | testes/locals.lua | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/testes/locals.lua b/testes/locals.lua index 1b43609b..add023ca 100644 --- a/testes/locals.lua +++ b/testes/locals.lua | |||
@@ -459,7 +459,22 @@ do -- errors due to non-closable values | |||
459 | getmetatable(xyz).__close = nil -- remove metamethod | 459 | getmetatable(xyz).__close = nil -- remove metamethod |
460 | end | 460 | end |
461 | local stat, msg = pcall(foo) | 461 | local stat, msg = pcall(foo) |
462 | assert(not stat and string.find(msg, "attempt to call a nil value")) | 462 | assert(not stat and string.find(msg, "metamethod 'close'")) |
463 | |||
464 | local function foo () | ||
465 | local a1 <close> = func2close(function (_, msg) | ||
466 | assert(string.find(msg, "number value")) | ||
467 | error(12) | ||
468 | end) | ||
469 | local a2 <close> = setmetatable({}, {__close = print}) | ||
470 | local a3 <close> = func2close(function (_, msg) | ||
471 | assert(msg == nil) | ||
472 | error(123) | ||
473 | end) | ||
474 | getmetatable(a2).__close = 4 -- invalidate metamethod | ||
475 | end | ||
476 | local stat, msg = pcall(foo) | ||
477 | assert(not stat and msg == 12) | ||
463 | end | 478 | end |
464 | 479 | ||
465 | 480 | ||