diff options
Diffstat (limited to 'testes')
| -rw-r--r-- | testes/db.lua | 6 | ||||
| -rw-r--r-- | testes/goto.lua | 18 |
2 files changed, 22 insertions, 2 deletions
diff --git a/testes/db.lua b/testes/db.lua index ae204c41..0f174f17 100644 --- a/testes/db.lua +++ b/testes/db.lua | |||
| @@ -349,9 +349,11 @@ end, "crl") | |||
| 349 | 349 | ||
| 350 | 350 | ||
| 351 | function f(a,b) | 351 | function f(a,b) |
| 352 | global collectgarbage, assert, g, string | 352 | -- declare some globals to check that they don't interfere with 'getlocal' |
| 353 | global collectgarbage | ||
| 353 | collectgarbage() | 354 | collectgarbage() |
| 354 | local _, x = debug.getlocal(1, 1) | 355 | local _, x = debug.getlocal(1, 1) |
| 356 | global assert, g, string | ||
| 355 | local _, y = debug.getlocal(1, 2) | 357 | local _, y = debug.getlocal(1, 2) |
| 356 | assert(x == a and y == b) | 358 | assert(x == a and y == b) |
| 357 | assert(debug.setlocal(2, 3, "pera") == "AA".."AA") | 359 | assert(debug.setlocal(2, 3, "pera") == "AA".."AA") |
| @@ -387,7 +389,9 @@ function g (...) | |||
| 387 | f(AAAA,B) | 389 | f(AAAA,B) |
| 388 | assert(AAAA == "pera" and B == "manga") | 390 | assert(AAAA == "pera" and B == "manga") |
| 389 | do | 391 | do |
| 392 | global * | ||
| 390 | local B = 13 | 393 | local B = 13 |
| 394 | global<const> assert | ||
| 391 | local x,y = debug.getlocal(1,5) | 395 | local x,y = debug.getlocal(1,5) |
| 392 | assert(x == 'B' and y == 13) | 396 | assert(x == 'B' and y == 13) |
| 393 | end | 397 | end |
diff --git a/testes/goto.lua b/testes/goto.lua index d7730061..7e40fc4f 100644 --- a/testes/goto.lua +++ b/testes/goto.lua | |||
| @@ -364,7 +364,23 @@ do | |||
| 364 | print(X) -- Ok to use | 364 | print(X) -- Ok to use |
| 365 | Y = 1 -- ERROR | 365 | Y = 1 -- ERROR |
| 366 | ]], "assign to const variable 'Y'") | 366 | ]], "assign to const variable 'Y'") |
| 367 | 367 | ||
| 368 | checkerr([[ | ||
| 369 | global *; | ||
| 370 | Y = X -- Ok to use | ||
| 371 | global<const> *; | ||
| 372 | Y = 1 -- ERROR | ||
| 373 | ]], "assign to const variable 'Y'") | ||
| 374 | |||
| 375 | global * | ||
| 376 | Y = 10 | ||
| 377 | assert(_ENV.Y == 10) | ||
| 378 | global<const> * | ||
| 379 | local x = Y | ||
| 380 | global * | ||
| 381 | Y = x + Y | ||
| 382 | assert(_ENV.Y == 20) | ||
| 383 | |||
| 368 | end | 384 | end |
| 369 | 385 | ||
| 370 | print'OK' | 386 | print'OK' |
