aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-04-12 19:23:08 +1000
committerdaurnimator <quae@daurnimator.com>2017-04-12 19:44:26 +1000
commitd2c29700b140c6656bc9cc4c8870f9f340b98945 (patch)
tree905db35dd914d20d8eecdbf1a4ea63632195573b /tests
parentb9d07132efcadde006a07eff7bd5ad27b4a6bd2e (diff)
downloadfengari-d2c29700b140c6656bc9cc4c8870f9f340b98945.tar.gz
fengari-d2c29700b140c6656bc9cc4c8870f9f340b98945.tar.bz2
fengari-d2c29700b140c6656bc9cc4c8870f9f340b98945.zip
Print returned values from cli
Diffstat (limited to 'tests')
-rwxr-xr-xtests/manual-tests/lua-cli.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/manual-tests/lua-cli.js b/tests/manual-tests/lua-cli.js
index 6938a8b..de64359 100755
--- a/tests/manual-tests/lua-cli.js
+++ b/tests/manual-tests/lua-cli.js
@@ -42,10 +42,20 @@ for (;;) {
lauxlib.lua_writestringerror(`${lapi.lua_tojsstring(L, -1)}\n`);
continue;
}
- if (lapi.lua_pcall(L, 0, 0, 0) !== lua.thread_status.LUA_OK) {
+ if (lapi.lua_pcall(L, 0, lua.LUA_MULTRET, 0) !== lua.thread_status.LUA_OK) {
lauxlib.lua_writestringerror(`${lapi.lua_tojsstring(L, -1)}\n`);
lapi.lua_settop(L, 0);
continue;
}
+ let n = lapi.lua_gettop(L);
+ if (n > 0) { /* any result to be printed? */
+ lapi.lua_getglobal(L, lua.to_luastring("print"));
+ lapi.lua_insert(L, 1);
+ if (lapi.lua_pcall(L, n, 0, 0) != lua.thread_status.LUA_OK) {
+ lauxlib.lua_writestringerror(`error calling 'print' (${lapi.lua_tojsstring(L, -1)})\n`);
+ lapi.lua_settop(L, 0);
+ continue;
+ }
+ }
lapi.lua_settop(L, 0); /* remove eventual returns */
}