summaryrefslogtreecommitdiff
path: root/tests/test-suite/ltests.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-06-19 00:54:11 +1000
committerdaurnimator <quae@daurnimator.com>2017-06-19 00:54:11 +1000
commit5928a46812aa108d7388e5ad3ed0c9aa4b6d5a61 (patch)
tree71b1d216f5211623b96b17408ea5312e7aff0e86 /tests/test-suite/ltests.js
parent098ea04c2a85a15e621269a6f4b38d3a607f47d0 (diff)
downloadfengari-5928a46812aa108d7388e5ad3ed0c9aa4b6d5a61.tar.gz
fengari-5928a46812aa108d7388e5ad3ed0c9aa4b6d5a61.tar.bz2
fengari-5928a46812aa108d7388e5ad3ed0c9aa4b6d5a61.zip
tests/test-suite: Fix checkpanic
Diffstat (limited to 'tests/test-suite/ltests.js')
-rw-r--r--tests/test-suite/ltests.js20
1 files changed, 9 insertions, 11 deletions
diff --git a/tests/test-suite/ltests.js b/tests/test-suite/ltests.js
index 4d53053..56a673c 100644
--- a/tests/test-suite/ltests.js
+++ b/tests/test-suite/ltests.js
@@ -662,11 +662,10 @@ const Chook = function(L, ar) {
runJS(L, L, { script: scpt, offset: 0 }); /* run script from C_HOOK[L] */
};
-class Aux {
+class Aux {
constructor() {
- this.jb = null;
this.paniccode = null;
- this.L = null;
+ this.L = null;
}
}
@@ -674,20 +673,19 @@ class Aux {
** does a long-jump back to "main program".
*/
const panicback = function(L) {
- let b = Aux();
+ let b = new Aux();
lua.lua_checkstack(L, 1); /* open space for 'Aux' struct */
lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, lua.to_luastring("_jmpbuf", true)); /* get 'Aux' struct */
b = lua.lua_touserdata(L, -1);
lua.lua_pop(L, 1); /* remove 'Aux' struct */
- runJS(b.L, L, b.paniccode); /* run optional panic code */
- longjmp(b.jb, 1); // TODO ?
- return 1; /* to avoid warnings */
+ runJS(b.L, L, { script: b.paniccode, offset: 0 }); /* run optional panic code */
+ throw 1;
};
const checkpanic = function(L) {
let b = new Aux();
let code = lauxlib.luaL_checkstring(L, 1);
- b.paniccode = lauxlib.luaL_optstring(L, 2, "");
+ b.paniccode = lauxlib.luaL_optstring(L, 2, lua.to_luastring("", true));
b.L = L;
let L1 = lua.lua_newstate(); /* create new state */
if (L1 === null) { /* error? */
@@ -697,10 +695,10 @@ const checkpanic = function(L) {
lua.lua_atpanic(L1, panicback); /* set its panic function */
lua.lua_pushlightuserdata(L1, b);
lua.lua_setfield(L1, lua.LUA_REGISTRYINDEX, lua.to_luastring("_jmpbuf", true)); /* store 'Aux' struct */
- if (setjmp(b.jb) === 0) { /* set jump buffer */ // TODO ?
- runJS(L, L1, code); /* run code unprotected */
+ try { /* set jump buffer */
+ runJS(L, L1, { script: code, offset: 0 }); /* run code unprotected */
lua.lua_pushliteral(L, "no errors");
- } else { /* error handling */
+ } catch (e) { /* error handling */
/* move error message to original state */
lua.lua_pushstring(L, lua.lua_tostring(L1, -1));
}