summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-02 11:13:33 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-03-02 11:13:33 +0100
commit8ffdadc19c526ae36490e626e226c6123ae2b3ff (patch)
tree00c8963bf8ab44f555f87bafa7a835f692083781 /tests
parent490ee0d109671b6f7e9d3d56e8122f41647fed4c (diff)
downloadfengari-8ffdadc19c526ae36490e626e226c6123ae2b3ff.tar.gz
fengari-8ffdadc19c526ae36490e626e226c6123ae2b3ff.tar.bz2
fengari-8ffdadc19c526ae36490e626e226c6123ae2b3ff.zip
[Parsing tests] SETTABLE, GETTABLE
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 7a12985..ca77054 100644
--- a/tests/lexparse.js
+++ b/tests/lexparse.js
@@ -533,4 +533,42 @@ test('FORPREP, FORLOOP (float)', function (t) {
60.5,
"Program output is correct"
);
+});
+
+
+test('SETTABLE, GETTABLE', function (t) {
+ let luaCode = `
+ local 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