diff options
Diffstat (limited to 'testes')
| -rw-r--r-- | testes/main.lua | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/testes/main.lua b/testes/main.lua index 52c77954..9def6386 100644 --- a/testes/main.lua +++ b/testes/main.lua | |||
| @@ -261,6 +261,34 @@ u2 = setmetatable({}, {__gc = function () error("ZYX") end}) | |||
| 261 | RUN('lua -W %s 2> %s', prog, out) | 261 | RUN('lua -W %s 2> %s', prog, out) |
| 262 | checkprogout("ZYX)\nXYZ)\n") | 262 | checkprogout("ZYX)\nXYZ)\n") |
| 263 | 263 | ||
| 264 | -- bug since 5.2: finalizer called when closing a state could | ||
| 265 | -- subvert finalization order | ||
| 266 | prepfile[[ | ||
| 267 | -- should be called last | ||
| 268 | print("creating 1") | ||
| 269 | setmetatable({}, {__gc = function () print(1) end}) | ||
| 270 | |||
| 271 | print("creating 2") | ||
| 272 | setmetatable({}, {__gc = function () | ||
| 273 | print("2") | ||
| 274 | print("creating 3") | ||
| 275 | -- this finalizer should not be called, as object will be | ||
| 276 | -- created after 'lua_close' has been called | ||
| 277 | setmetatable({}, {__gc = function () print(3) end}) | ||
| 278 | print(collectgarbage()) -- cannot call collector here | ||
| 279 | os.exit(0, true) | ||
| 280 | end}) | ||
| 281 | ]] | ||
| 282 | RUN('lua -W %s > %s', prog, out) | ||
| 283 | checkout[[ | ||
| 284 | creating 1 | ||
| 285 | creating 2 | ||
| 286 | 2 | ||
| 287 | creating 3 | ||
| 288 | nil | ||
| 289 | 1 | ||
| 290 | ]] | ||
| 291 | |||
| 264 | 292 | ||
| 265 | -- test many arguments | 293 | -- test many arguments |
| 266 | prepfile[[print(({...})[30])]] | 294 | prepfile[[print(({...})[30])]] |
