diff options
Diffstat (limited to 'testes/db.lua')
-rw-r--r-- | testes/db.lua | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/testes/db.lua b/testes/db.lua index 3c821ab7..0f174f17 100644 --- a/testes/db.lua +++ b/testes/db.lua | |||
@@ -349,8 +349,11 @@ end, "crl") | |||
349 | 349 | ||
350 | 350 | ||
351 | function f(a,b) | 351 | function f(a,b) |
352 | -- declare some globals to check that they don't interfere with 'getlocal' | ||
353 | global collectgarbage | ||
352 | collectgarbage() | 354 | collectgarbage() |
353 | local _, x = debug.getlocal(1, 1) | 355 | local _, x = debug.getlocal(1, 1) |
356 | global assert, g, string | ||
354 | local _, y = debug.getlocal(1, 2) | 357 | local _, y = debug.getlocal(1, 2) |
355 | assert(x == a and y == b) | 358 | assert(x == a and y == b) |
356 | assert(debug.setlocal(2, 3, "pera") == "AA".."AA") | 359 | assert(debug.setlocal(2, 3, "pera") == "AA".."AA") |
@@ -386,7 +389,9 @@ function g (...) | |||
386 | f(AAAA,B) | 389 | f(AAAA,B) |
387 | assert(AAAA == "pera" and B == "manga") | 390 | assert(AAAA == "pera" and B == "manga") |
388 | do | 391 | do |
392 | global * | ||
389 | local B = 13 | 393 | local B = 13 |
394 | global<const> assert | ||
390 | local x,y = debug.getlocal(1,5) | 395 | local x,y = debug.getlocal(1,5) |
391 | assert(x == 'B' and y == 13) | 396 | assert(x == 'B' and y == 13) |
392 | end | 397 | end |
@@ -431,7 +436,7 @@ do | |||
431 | assert(a == nil and not b) | 436 | assert(a == nil and not b) |
432 | end | 437 | end |
433 | 438 | ||
434 | -- testing iteraction between multiple values x hooks | 439 | -- testing interaction between multiple values x hooks |
435 | do | 440 | do |
436 | local function f(...) return 3, ... end | 441 | local function f(...) return 3, ... end |
437 | local count = 0 | 442 | local count = 0 |
@@ -587,7 +592,7 @@ t = getupvalues(foo2) | |||
587 | assert(t.a == 1 and t.b == 2 and t.c == 3) | 592 | assert(t.a == 1 and t.b == 2 and t.c == 3) |
588 | assert(debug.setupvalue(foo1, 1, "xuxu") == "b") | 593 | assert(debug.setupvalue(foo1, 1, "xuxu") == "b") |
589 | assert(({debug.getupvalue(foo2, 3)})[2] == "xuxu") | 594 | assert(({debug.getupvalue(foo2, 3)})[2] == "xuxu") |
590 | -- upvalues of C functions are allways "called" "" (the empty string) | 595 | -- upvalues of C functions are always named "" (the empty string) |
591 | assert(debug.getupvalue(string.gmatch("x", "x"), 1) == "") | 596 | assert(debug.getupvalue(string.gmatch("x", "x"), 1) == "") |
592 | 597 | ||
593 | 598 | ||
@@ -701,7 +706,7 @@ assert(debug.traceback(print, 4) == print) | |||
701 | assert(string.find(debug.traceback("hi", 4), "^hi\n")) | 706 | assert(string.find(debug.traceback("hi", 4), "^hi\n")) |
702 | assert(string.find(debug.traceback("hi"), "^hi\n")) | 707 | assert(string.find(debug.traceback("hi"), "^hi\n")) |
703 | assert(not string.find(debug.traceback("hi"), "'debug.traceback'")) | 708 | assert(not string.find(debug.traceback("hi"), "'debug.traceback'")) |
704 | assert(string.find(debug.traceback("hi", 0), "'debug.traceback'")) | 709 | assert(string.find(debug.traceback("hi", 0), "'traceback'")) |
705 | assert(string.find(debug.traceback(), "^stack traceback:\n")) | 710 | assert(string.find(debug.traceback(), "^stack traceback:\n")) |
706 | 711 | ||
707 | do -- C-function names in traceback | 712 | do -- C-function names in traceback |
@@ -829,7 +834,7 @@ end | |||
829 | 834 | ||
830 | co = coroutine.create(function (x) f(x) end) | 835 | co = coroutine.create(function (x) f(x) end) |
831 | a, b = coroutine.resume(co, 3) | 836 | a, b = coroutine.resume(co, 3) |
832 | t = {"'coroutine.yield'", "'f'", "in function <"} | 837 | t = {"'yield'", "'f'", "in function <"} |
833 | while coroutine.status(co) == "suspended" do | 838 | while coroutine.status(co) == "suspended" do |
834 | checktraceback(co, t) | 839 | checktraceback(co, t) |
835 | a, b = coroutine.resume(co) | 840 | a, b = coroutine.resume(co) |
@@ -839,7 +844,7 @@ t[1] = "'error'" | |||
839 | checktraceback(co, t) | 844 | checktraceback(co, t) |
840 | 845 | ||
841 | 846 | ||
842 | -- test acessing line numbers of a coroutine from a resume inside | 847 | -- test accessing line numbers of a coroutine from a resume inside |
843 | -- a C function (this is a known bug in Lua 5.0) | 848 | -- a C function (this is a known bug in Lua 5.0) |
844 | 849 | ||
845 | local function g(x) | 850 | local function g(x) |
@@ -966,9 +971,9 @@ local debug = require'debug' | |||
966 | local a = 12 -- a local variable | 971 | local a = 12 -- a local variable |
967 | 972 | ||
968 | local n, v = debug.getlocal(1, 1) | 973 | local n, v = debug.getlocal(1, 1) |
969 | assert(n == "(temporary)" and v == debug) -- unkown name but known value | 974 | assert(n == "(temporary)" and v == debug) -- unknown name but known value |
970 | n, v = debug.getlocal(1, 2) | 975 | n, v = debug.getlocal(1, 2) |
971 | assert(n == "(temporary)" and v == 12) -- unkown name but known value | 976 | assert(n == "(temporary)" and v == 12) -- unknown name but known value |
972 | 977 | ||
973 | -- a function with an upvalue | 978 | -- a function with an upvalue |
974 | local f = function () local x; return a end | 979 | local f = function () local x; return a end |
@@ -1018,7 +1023,7 @@ do -- bug in 5.4.0: line hooks in stripped code | |||
1018 | line = l | 1023 | line = l |
1019 | end, "l") | 1024 | end, "l") |
1020 | assert(s() == 2); debug.sethook(nil) | 1025 | assert(s() == 2); debug.sethook(nil) |
1021 | assert(line == nil) -- hook called withoug debug info for 1st instruction | 1026 | assert(line == nil) -- hook called without debug info for 1st instruction |
1022 | end | 1027 | end |
1023 | 1028 | ||
1024 | do -- tests for 'source' in binary dumps | 1029 | do -- tests for 'source' in binary dumps |