Hi, Sergey thanks for the patch! see my comments below. On 14.08.2024 16:55, Sergey Kaplun wrote: > This patch moves the aforementioned test from the to the why and not a "debug" suite? > directory, includes it in , names the subtests, and adjusts the > linenumbers in the assertions to match LuaJIT behaviour and the new code Split "linenumbers" to two words, or wrap with backticks (I suspect you mean a field in getinfo). > layout. + formatting changes > > Part of tarantool/tarantool#9398 > --- > test/LuaJIT-tests/lang/hook_line.lua | 44 ++++++++++++++++++++++++++++ > test/LuaJIT-tests/lang/index | 1 + > test/LuaJIT-tests/misc/hook_line.lua | 41 -------------------------- > 3 files changed, 45 insertions(+), 41 deletions(-) > create mode 100644 test/LuaJIT-tests/lang/hook_line.lua > delete mode 100644 test/LuaJIT-tests/misc/hook_line.lua > > diff --git a/test/LuaJIT-tests/lang/hook_line.lua b/test/LuaJIT-tests/lang/hook_line.lua > new file mode 100644 > index 00000000..bb89c4b8 > --- /dev/null > +++ b/test/LuaJIT-tests/lang/hook_line.lua > @@ -0,0 +1,44 @@ > +local lines = {} > +local function hook() > + lines[#lines + 1] = debug.getinfo(2).currentline > +end > + > +local function dummy() > +end -- <-- line 7 > + > +do --- Base test: cycles, function calls. > + debug.sethook(hook, "l", 0) > + -- <-- line 11 > + local x > + dummy() > + local y = 1 > + dummy() dummy() > + local z = 2; local r = true > + while y < 4 do y = y + 1 end > + while z < 4 do > + z = z + 1 > + end > + -- <-- line 21 > + local v > + debug.sethook(nil, "", 0) > + > + assert(#lines > 0) > + while lines[1] < 10 do table.remove(lines, 1) end > + while lines[#lines] > 20 do table.remove(lines) end > + > + local s = table.concat(lines, " ") > + assert(s == "12 13 7 14 15 7 7 16 17 17 17 17 18 19 18 19 18" or > + s == "12 13 7 14 15 7 15 7 16 17 17 17 17 18 19 18 19 18") > +end > + > +do --- Not visited the end of the function definition. > + lines = {} > + local function f() > + if true then return end > + local function x() end > + end -- <-- line 39 test depends on a number of lines in the file, please add a note about it at the beginning of the file > + debug.sethook(hook, "l", 0) > + f() > + debug.sethook(nil, "", 0) > + for i = 1, #lines do assert(lines[i] ~= 39) end > +end > diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index > index 8cecfa08..ae59bc56 100644 > --- a/test/LuaJIT-tests/lang/index > +++ b/test/LuaJIT-tests/lang/index > @@ -9,6 +9,7 @@ constant > dualnum.lua > for.lua > hook_active.lua > +hook_line.lua > length.lua > lightud.lua > modulo.lua > diff --git a/test/LuaJIT-tests/misc/hook_line.lua b/test/LuaJIT-tests/misc/hook_line.lua > deleted file mode 100644 > index 36f71080..00000000 > --- a/test/LuaJIT-tests/misc/hook_line.lua > +++ /dev/null > @@ -1,41 +0,0 @@ > -local lines = {} > -local function hook() > - lines[#lines+1] = debug.getinfo(2).currentline > -end > - > -local function dummy() > -end -- <-- line 7 > - > -debug.sethook(hook, "l", 0) > --- <-- line 10 > -local x > -dummy() > -local y = 1 > -dummy() dummy() > -local z = 2; local r = true > -while y < 4 do y = y + 1 end > -while z < 4 do > - z = z + 1 > -end > --- <-- line 20 > -local v > -debug.sethook(nil, "", 0) > - > -assert(#lines > 0) > -while lines[1] < 10 do table.remove(lines, 1) end > -while lines[#lines] > 20 do table.remove(lines) end > - > -local s = table.concat(lines, " ") > -assert(s == "11 12 7 13 14 7 7 15 16 16 16 16 17 18 17 18 17" or > - s == "11 12 7 13 14 7 14 7 15 16 16 16 16 17 18 17 18 17") > - > -lines = {} > -local function f() > - if true then return end > - local function x() end > -end -- <-- line 36 > -debug.sethook(hook, "l", 0) > -f() > -debug.sethook(nil, "", 0) > -for i=1,#lines do assert(lines[i] ~= 36) end > -