aboutsummaryrefslogtreecommitdiff
path: root/testes/db.lua
diff options
context:
space:
mode:
Diffstat (limited to 'testes/db.lua')
-rw-r--r--testes/db.lua21
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
351function f(a,b) 351function 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)
432end 437end
433 438
434-- testing iteraction between multiple values x hooks 439-- testing interaction between multiple values x hooks
435do 440do
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)
587assert(t.a == 1 and t.b == 2 and t.c == 3) 592assert(t.a == 1 and t.b == 2 and t.c == 3)
588assert(debug.setupvalue(foo1, 1, "xuxu") == "b") 593assert(debug.setupvalue(foo1, 1, "xuxu") == "b")
589assert(({debug.getupvalue(foo2, 3)})[2] == "xuxu") 594assert(({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)
591assert(debug.getupvalue(string.gmatch("x", "x"), 1) == "") 596assert(debug.getupvalue(string.gmatch("x", "x"), 1) == "")
592 597
593 598
@@ -701,7 +706,7 @@ assert(debug.traceback(print, 4) == print)
701assert(string.find(debug.traceback("hi", 4), "^hi\n")) 706assert(string.find(debug.traceback("hi", 4), "^hi\n"))
702assert(string.find(debug.traceback("hi"), "^hi\n")) 707assert(string.find(debug.traceback("hi"), "^hi\n"))
703assert(not string.find(debug.traceback("hi"), "'debug.traceback'")) 708assert(not string.find(debug.traceback("hi"), "'debug.traceback'"))
704assert(string.find(debug.traceback("hi", 0), "'debug.traceback'")) 709assert(string.find(debug.traceback("hi", 0), "'traceback'"))
705assert(string.find(debug.traceback(), "^stack traceback:\n")) 710assert(string.find(debug.traceback(), "^stack traceback:\n"))
706 711
707do -- C-function names in traceback 712do -- C-function names in traceback
@@ -829,7 +834,7 @@ end
829 834
830co = coroutine.create(function (x) f(x) end) 835co = coroutine.create(function (x) f(x) end)
831a, b = coroutine.resume(co, 3) 836a, b = coroutine.resume(co, 3)
832t = {"'coroutine.yield'", "'f'", "in function <"} 837t = {"'yield'", "'f'", "in function <"}
833while coroutine.status(co) == "suspended" do 838while 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'"
839checktraceback(co, t) 844checktraceback(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
845local function g(x) 850local function g(x)
@@ -966,9 +971,9 @@ local debug = require'debug'
966local a = 12 -- a local variable 971local a = 12 -- a local variable
967 972
968local n, v = debug.getlocal(1, 1) 973local n, v = debug.getlocal(1, 1)
969assert(n == "(temporary)" and v == debug) -- unkown name but known value 974assert(n == "(temporary)" and v == debug) -- unknown name but known value
970n, v = debug.getlocal(1, 2) 975n, v = debug.getlocal(1, 2)
971assert(n == "(temporary)" and v == 12) -- unkown name but known value 976assert(n == "(temporary)" and v == 12) -- unknown name but known value
972 977
973-- a function with an upvalue 978-- a function with an upvalue
974local f = function () local x; return a end 979local 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
1022end 1027end
1023 1028
1024do -- tests for 'source' in binary dumps 1029do -- tests for 'source' in binary dumps