diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-31 11:22:39 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-07-31 11:22:39 -0300 |
| commit | fe040633a1d64af4c19acc4707adb47413a3cd4a (patch) | |
| tree | e6b690efda6a39ce6cea342dd73380dfa47c8b9f /testes | |
| parent | f645d3157372c73573dff221c5b26691cb0e7d56 (diff) | |
| download | lua-fe040633a1d64af4c19acc4707adb47413a3cd4a.tar.gz lua-fe040633a1d64af4c19acc4707adb47413a3cd4a.tar.bz2 lua-fe040633a1d64af4c19acc4707adb47413a3cd4a.zip | |
Tracebacks recognize metamethods '__close'
Diffstat (limited to 'testes')
| -rw-r--r-- | testes/locals.lua | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/testes/locals.lua b/testes/locals.lua index 6eb1ba0e..99fa79cd 100644 --- a/testes/locals.lua +++ b/testes/locals.lua | |||
| @@ -316,14 +316,27 @@ do -- errors in __close | |||
| 316 | assert(log[1] == 5 and log[2] == 4 and log[3] == 4 and log[4] == 4 | 316 | assert(log[1] == 5 and log[2] == 4 and log[3] == 4 and log[4] == 4 |
| 317 | and #log == 4) | 317 | and #log == 4) |
| 318 | 318 | ||
| 319 | -- error leaving a block | ||
| 320 | local function foo (...) | ||
| 321 | do | ||
| 322 | local x1 <close> = func2close(function () error("Y") end) | ||
| 323 | local x123 <close> = func2close(function () error("X") end) | ||
| 324 | end | ||
| 325 | end | ||
| 326 | |||
| 327 | local st, msg = xpcall(foo, debug.traceback) | ||
| 328 | assert(string.match(msg, "^[^ ]* X")) | ||
| 329 | assert(string.find(msg, "in metamethod 'close'")) | ||
| 330 | |||
| 319 | -- error in toclose in vararg function | 331 | -- error in toclose in vararg function |
| 320 | function foo (...) | 332 | local function foo (...) |
| 321 | local x123 <close> = 10 | 333 | local x123 <close> = func2close(function () error("X") end) |
| 322 | end | 334 | end |
| 323 | 335 | ||
| 324 | local st, msg = pcall(foo) | 336 | local st, msg = xpcall(foo, debug.traceback) |
| 325 | assert(string.find(msg, "'x123'")) | 337 | assert(string.match(msg, "^[^ ]* X")) |
| 326 | 338 | ||
| 339 | assert(string.find(msg, "in metamethod 'close'")) | ||
| 327 | end | 340 | end |
| 328 | 341 | ||
| 329 | 342 | ||
