From b618b835c74a8637e00ba1f4adf6b8884d360d43 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Fri, 3 Feb 2017 15:59:29 +0100 Subject: Table, metatable --- tests/lvm.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests') diff --git a/tests/lvm.js b/tests/lvm.js index 6a4ed9f..1dbff2e 100644 --- a/tests/lvm.js +++ b/tests/lvm.js @@ -10,6 +10,7 @@ const DataView = require('buffer-dataview'); const BytecodeParser = require("../src/lundump.js"); const lua_State = require("../src/lstate.js").lua_State; const LuaVM = require("../src/lvm.js").LuaVM; +const Table = require("../src/lobject.js").Table; const toByteCode = function (luaCode) { var luaFile = tmp.fileSync(), @@ -134,4 +135,26 @@ test('Unary op, LOADBOOL', function (t) { [-5, true, -6], "Program output is correct" ); +}); + + +test('NEWTABLE', function (t) { + let luaCode = ` + local a = {} + return a + `, vm; + + t.plan(2); + + t.comment("Running following code: \n" + luaCode); + + t.doesNotThrow(function () { + vm = getVM(luaCode); + vm.execute(); + }, "Program executed without errors"); + + t.ok( + vm.L.stack[0] instanceof Table, + "Program output is correct" + ); }); \ No newline at end of file -- cgit v1.2.3-54-g00ecf