aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-08 11:15:56 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-08 11:15:56 +0100
commit7d63489f2615609e21befc9d21a0e9f8fe2bf61a (patch)
tree4513b89e976963986499a45ce0328923fc947a25 /tests
parentd28b76c80bf49c31a5513c3de1b0c7a4d0ca6322 (diff)
downloadfengari-7d63489f2615609e21befc9d21a0e9f8fe2bf61a.tar.gz
fengari-7d63489f2615609e21befc9d21a0e9f8fe2bf61a.tar.bz2
fengari-7d63489f2615609e21befc9d21a0e9f8fe2bf61a.zip
OP_GETTABLE, OP_SETTABLE, metatable
Diffstat (limited to 'tests')
-rw-r--r--tests/lvm.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/lvm.js b/tests/lvm.js
index 5f19455..4c10521 100644
--- a/tests/lvm.js
+++ b/tests/lvm.js
@@ -450,4 +450,37 @@ test('TEST (false)', function (t) {
"goodbye",
"Program output is correct"
);
+});
+
+
+test('SETTABLE, GETTABLE', function (t) {
+ let luaCode = `
+ local t = {}
+
+ t[1] = "hello"
+ t["two"] = "world"
+
+ return t[1], t["two"]
+ `, vm;
+
+ t.plan(2);
+
+ t.comment("Running following code: \n" + luaCode);
+
+ t.doesNotThrow(function () {
+ vm = getVM(luaCode);
+ vm.execute();
+ }, "Program executed without errors");
+
+ t.stritEqual(
+ vm.L.stack[vm.L.top - 1].value.array[1],
+ "hello",
+ "Program output is correct"
+ );
+
+ t.stritEqual(
+ vm.L.stack[vm.L.top - 1].value.hash.get("two"),
+ "world",
+ "Program output is correct"
+ );
}); \ No newline at end of file