diff options
author | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-03-01 15:12:11 +0100 |
---|---|---|
committer | Benoit Giannangeli <benoit.giannangeli@boursorama.fr> | 2017-03-01 15:12:11 +0100 |
commit | 3da8070fa77b518baeba0cdea7265f7d41f497fe (patch) | |
tree | 458b70265783135b0dbd6e0b7a8db67e52fe7efd /tests/lexparse.js | |
parent | 699630a97161ef970c40af073f2943c7d90043e7 (diff) | |
download | fengari-3da8070fa77b518baeba0cdea7265f7d41f497fe.tar.gz fengari-3da8070fa77b518baeba0cdea7265f7d41f497fe.tar.bz2 fengari-3da8070fa77b518baeba0cdea7265f7d41f497fe.zip |
[Parsing tests] NEWTABLE
Diffstat (limited to 'tests/lexparse.js')
-rw-r--r-- | tests/lexparse.js | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/tests/lexparse.js b/tests/lexparse.js index 1a1a7b3..1132ef1 100644 --- a/tests/lexparse.js +++ b/tests/lexparse.js @@ -9,6 +9,7 @@ const toByteCode = tests.toByteCode; const lapi = require("../src/lapi.js"); const lauxlib = require("../src/lauxlib.js"); const linit = require('../src/linit.js'); +const Table = require("../src/lobject.js").Table; // Roughly the same tests as test/lvm.js to cover all opcodes @@ -108,9 +109,9 @@ test('Unary op, LOADBOOL', function (t) { return -a, not b, ~a `, L; - t.plan(1); + t.plan(2); - // t.doesNotThrow(function () { + t.doesNotThrow(function () { L = lauxlib.luaL_newstate(); @@ -120,7 +121,7 @@ test('Unary op, LOADBOOL', function (t) { lapi.lua_call(L, 0, -1); - // }, "JS Lua program ran without error"); + }, "JS Lua program ran without error"); t.deepEqual( L.stack.slice(L.top - 3, L.top).map(e => e.value), @@ -128,3 +129,30 @@ test('Unary op, LOADBOOL', function (t) { "Program output is correct" ); }); + + +test('NEWTABLE', function (t) { + let luaCode = ` + local a = {} + return a + `, L; + + t.plan(2); + + 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.ok( + L.stack[lapi.index2addr_(L, -1)] instanceof Table, + "Program output is correct" + ); +});
\ No newline at end of file |