summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-06-16 17:18:53 +1000
committerdaurnimator <quae@daurnimator.com>2017-06-16 18:06:42 +1000
commit1f59eebdd76692ad0f68239bdd45f0e8b84882ce (patch)
tree6dbcd173ff93a04c96715064a6b3902cfd4712d8 /tests
parent83eadc932dd0100a7dac254d8ba92a7e02deddd8 (diff)
downloadfengari-1f59eebdd76692ad0f68239bdd45f0e8b84882ce.tar.gz
fengari-1f59eebdd76692ad0f68239bdd45f0e8b84882ce.tar.bz2
fengari-1f59eebdd76692ad0f68239bdd45f0e8b84882ce.zip
tests/test-suite/inprogress/db.js: Fix first test
Diffstat (limited to 'tests')
-rw-r--r--tests/test-suite/inprogress/db.js72
1 files changed, 20 insertions, 52 deletions
diff --git a/tests/test-suite/inprogress/db.js b/tests/test-suite/inprogress/db.js
index 2481096..85dd5c0 100644
--- a/tests/test-suite/inprogress/db.js
+++ b/tests/test-suite/inprogress/db.js
@@ -12,9 +12,9 @@ const lualib = require('../../../src/lualib.js');
const prefix = `
local function dostring(s) return assert(load(s))() end
- local testline = 4 -- line where 'test' is defined
- function test (s, l, p) -- this must be line 4
- -- collectgarbage() -- avoid gc during trace
+ local testline = 5 -- line where 'test' is defined
+ function test (s, l, p) -- this must be line 5
+ local a = 1 -- do something that's active instead of collectgarbage()
local function f (event, line)
assert(event == 'line')
local l = table.remove(l, 1)
@@ -27,54 +27,22 @@ const prefix = `
`;
test("[test-suite] db: getinfo, ...line...", function (t) {
- let luaCode = `-- $Id: db.lua,v 1.79 2016/11/07 13:02:34 roberto Exp $
- -- See Copyright Notice in file all.lua
-
- -- testing debug library
-
- local debug = require "debug"
-
- local function dostring(s) return assert(load(s))() end
-
- print"testing debug library and debug information"
-
- do
- local a=1
- end
-
- assert(not debug.gethook())
-
- local testline = 19 -- line where 'test' is defined
- function test (s, l, p) -- this must be line 19
- collectgarbage() -- avoid gc during trace
- local function f (event, line)
- assert(event == 'line')
- local l = table.remove(l, 1)
- if p then print(l, line) end
- assert(l == line, "wrong trace!!")
- end
- debug.sethook(f,"l"); load(s)(); debug.sethook()
- assert(#l == 0)
- end
-
-
- do
- assert(not pcall(debug.getinfo, print, "X")) -- invalid option
- assert(not debug.getinfo(1000)) -- out of range level
- assert(not debug.getinfo(-1)) -- out of range level
- local a = debug.getinfo(print)
- assert(a.what == "J" and a.short_src == "[JS]")
- a = debug.getinfo(print, "L")
- assert(a.activelines == nil)
- local b = debug.getinfo(test, "SfL")
- assert(b.name == nil and b.what == "Lua" and b.linedefined == testline and
- b.lastlinedefined == b.linedefined + 10 and
- b.func == test and string.find(b.short_src, "%["))
- assert(b.activelines[b.linedefined + 1] and
- b.activelines[b.lastlinedefined])
- assert(not b.activelines[b.linedefined] and
- not b.activelines[b.lastlinedefined + 1])
- end
+ let luaCode = `
+ assert(not pcall(debug.getinfo, print, "X")) -- invalid option
+ assert(not debug.getinfo(1000)) -- out of range level
+ assert(not debug.getinfo(-1)) -- out of range level
+ local a = debug.getinfo(print)
+ assert(a.what == "J" and a.short_src == "[JS]")
+ a = debug.getinfo(print, "L")
+ assert(a.activelines == nil)
+ local b = debug.getinfo(test, "SfL")
+ assert(b.name == nil and b.what == "Lua" and b.linedefined == testline and
+ b.lastlinedefined == b.linedefined + 10 and
+ b.func == test and string.find(b.short_src, "%["))
+ assert(b.activelines[b.linedefined + 1] and
+ b.activelines[b.lastlinedefined])
+ assert(not b.activelines[b.linedefined] and
+ not b.activelines[b.lastlinedefined + 1])
`, L;
t.plan(2);
@@ -85,7 +53,7 @@ test("[test-suite] db: getinfo, ...line...", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
}, "Lua program loaded without error");