diff options
Diffstat (limited to 'tests/lexparse.js')
-rw-r--r-- | tests/lexparse.js | 117 |
1 files changed, 58 insertions, 59 deletions
diff --git a/tests/lexparse.js b/tests/lexparse.js index ca57605..e9087ee 100644 --- a/tests/lexparse.js +++ b/tests/lexparse.js @@ -5,9 +5,8 @@ const test = require('tape'); const lua = require('../src/lua.js'); const lauxlib = require('../src/lauxlib.js'); const lualib = require('../src/lualib.js'); -const lapi = require('../src/lapi.js'); const lstring = require("../src/lstring.js"); - +const {to_luastring} = require("../src/fengaricore.js"); // Roughly the same tests as test/lvm.js to cover all opcodes test('LOADK, RETURN', function (t) { @@ -27,10 +26,10 @@ test('LOADK, RETURN', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -67,10 +66,10 @@ test('MOVE', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -107,10 +106,10 @@ test('Binary op', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -147,10 +146,10 @@ test('Unary op, LOADBOOL', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -185,10 +184,10 @@ test('NEWTABLE', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -199,7 +198,7 @@ test('NEWTABLE', function (t) { }, "Lua program ran without error"); t.ok( - L.stack[lapi.index2addr_(L, -1)].ttistable(), + lua.lua_type(L, -1) === lua.LUA_TTABLE, "Program output is correct" ); }); @@ -227,10 +226,10 @@ test('CALL', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -273,10 +272,10 @@ test('Multiple return', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -314,10 +313,10 @@ test('TAILCALL', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -355,10 +354,10 @@ test('VARARG', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -394,10 +393,10 @@ test('LE, JMP', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -433,10 +432,10 @@ test('LT', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -472,10 +471,10 @@ test('EQ', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -512,10 +511,10 @@ test('TESTSET (and)', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -552,10 +551,10 @@ test('TESTSET (or)', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -596,10 +595,10 @@ test('TEST (false)', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -639,10 +638,10 @@ test('FORPREP, FORLOOP (int)', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -682,10 +681,10 @@ test('FORPREP, FORLOOP (float)', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -724,10 +723,10 @@ test('SETTABLE, GETTABLE', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -744,7 +743,7 @@ test('SETTABLE, GETTABLE', function (t) { ); t.strictEqual( - lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(lua.to_luastring("two"))).value.jsstring(), + lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring(), "world", "Program output is correct" ); @@ -775,10 +774,10 @@ test('SETUPVAL, GETUPVAL', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -817,10 +816,10 @@ test('SETTABUP, GETTABUP', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -837,7 +836,7 @@ test('SETTABUP, GETTABUP', function (t) { ); t.strictEqual( - lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(lua.to_luastring("two"))).value.jsstring(), + lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring(), "world", "Program output is correct" ); @@ -867,10 +866,10 @@ test('SELF', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -906,10 +905,10 @@ test('SETLIST', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -949,10 +948,10 @@ test('Variable SETLIST', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -987,10 +986,10 @@ test('Long SETLIST', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -1042,10 +1041,10 @@ test('TFORCALL, TFORLOOP', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -1083,10 +1082,10 @@ test('LEN', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); @@ -1132,10 +1131,10 @@ test('CONCAT', function (t) { let reader = function(L, data) { let code = luaCode ? luaCode.trim() : null; luaCode = null; - return code ? lua.to_luastring(code) : null; + return code ? to_luastring(code) : null; }; - lua.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text")); + lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text")); }, "Lua program loaded without error"); |