summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-02 11:31:05 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-02 11:31:05 +0100
commitaee0f65dea0456635e96b4496f6597188526e647 (patch)
tree3afcb057b08b3a6b7ce091111e7be0db236ff3f4 /tests
parenteb838303ed7c3ddc2da0665ed0b5ca3843bf7b96 (diff)
downloadfengari-aee0f65dea0456635e96b4496f6597188526e647.tar.gz
fengari-aee0f65dea0456635e96b4496f6597188526e647.tar.bz2
fengari-aee0f65dea0456635e96b4496f6597188526e647.zip
[Parsing tests] SETTABUP, GETTABUP
Diffstat (limited to 'tests')
-rw-r--r--tests/lexparse.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/lexparse.js b/tests/lexparse.js
index 50b9c3f..e819c3c 100644
--- a/tests/lexparse.js
+++ b/tests/lexparse.js
@@ -606,4 +606,42 @@ test('SETUPVAL, GETUPVAL', function (t) {
"world",
"Program output is correct"
);
+});
+
+
+test('SETTABUP, GETTABUP', function (t) {
+ let luaCode = `
+ t = {}
+
+ t[1] = "hello"
+ t["two"] = "world"
+
+ return t
+ `, L;
+
+ t.plan(3);
+
+ t.doesNotThrow(function () {
+
+ L = lauxlib.luaL_newstate();
+
+ linit.luaL_openlibs(L);
+
+ lapi.lua_load(L, null, luaCode, "test", "text");
+
+ lapi.lua_call(L, 0, -1);
+
+ }, "JS Lua program ran without error");
+
+ t.strictEqual(
+ lapi.lua_topointer(L, -1).get(0).value,
+ "hello",
+ "Program output is correct"
+ );
+
+ t.strictEqual(
+ lapi.lua_topointer(L, -1).get("two").value,
+ "world",
+ "Program output is correct"
+ );
}); \ No newline at end of file