From 3cb56ad565fca7408eaaacb74fe8ccfcd92729e1 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Thu, 25 May 2017 15:11:21 +0200 Subject: ar.what was not a lua string --- src/ldebug.js | 2 +- tests/test-suite/inprogress/coroutine.js | 36 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/ldebug.js b/src/ldebug.js index 5749951..0f387af 100644 --- a/src/ldebug.js +++ b/src/ldebug.js @@ -167,7 +167,7 @@ const funcinfo = function(ar, cl) { ar.source = defs.to_luastring("=[JS]", true); ar.linedefined = -1; ar.lastlinedefined = -1; - ar.what = "J"; + ar.what = ["J".charCodeAt(0)]; } else { let p = cl.p; ar.source = p.source ? p.source.getstr() : defs.to_luastring("=?", true); diff --git a/tests/test-suite/inprogress/coroutine.js b/tests/test-suite/inprogress/coroutine.js index 93be6df..8bf2664 100644 --- a/tests/test-suite/inprogress/coroutine.js +++ b/tests/test-suite/inprogress/coroutine.js @@ -1161,6 +1161,42 @@ test("[test-suite] coroutine: testing debug library on a coroutine suspended ins }); +test("[test-suite] coroutine: testing debug library on last function in a suspended coroutine", function (t) { + let luaCode = ` + do + -- testing debug library on last function in a suspended coroutine + -- (bug in 5.2/5.3) + local c = coroutine.create(function () T.testC("yield 1", 10, 20) end) + local a, b = coroutine.resume(c) + assert(a and b == 20) + assert(debug.getinfo(c, 0).linedefined == -1) + a, b = debug.getlocal(c, 0, 2) + assert(b == 10) + end + `, L; + + t.plan(2); + + t.doesNotThrow(function () { + + L = lauxlib.luaL_newstate(); + + lualib.luaL_openlibs(L); + + ltests.luaopen_tests(L); + + lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode)); + + }, "Lua program loaded without error"); + + t.doesNotThrow(function () { + + lua.lua_call(L, 0, -1); + + }, "Lua program ran without error"); +}); + + test("[test-suite] coroutine: tests for coroutine API", { skip: true }, function (t) { t.comment("TODO"); }); -- cgit v1.2.3-54-g00ecf