From a39f24f204a15cb4587e75b38424952fe444d9d2 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Thu, 11 Jan 2018 23:33:34 +1100 Subject: Move fengari specific things to src/fengaricore.js String manipulation functions now get exposed on 'fengari' object itself at top level --- tests/lapi.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'tests/lapi.js') diff --git a/tests/lapi.js b/tests/lapi.js index a63ae66..56859d8 100644 --- a/tests/lapi.js +++ b/tests/lapi.js @@ -5,8 +5,9 @@ const test = require('tape'); const tests = require("./tests.js"); const toByteCode = tests.toByteCode; -const lauxlib = require("../src/lauxlib.js"); const lua = require('../src/lua.js'); +const lauxlib = require("../src/lauxlib.js"); +const {to_luastring} = require("../src/fengaricore.js"); test('luaL_newstate, lua_pushnil, luaL_typename', function (t) { let L; @@ -369,7 +370,7 @@ test('lua_load with no chunkname', function (t) { t.doesNotThrow(function () { L = lauxlib.luaL_newstate(); - lua.lua_load(L, function(L, s) { let r = s.code; s.code = null; return r; }, {code: lua.to_luastring("return 'hello'")}, null, null); + lua.lua_load(L, function(L, s) { let r = s.code; s.code = null; return r; }, {code: to_luastring("return 'hello'")}, null, null); lua.lua_call(L, 0, 1); }, "JS Lua program ran without error"); @@ -395,7 +396,7 @@ test('lua_load and lua_call it', function (t) { L = lauxlib.luaL_newstate(); - lua.lua_load(L, function(L, s) { let r = s.bc; s.bc = null; return r; }, {bc: bc}, lua.to_luastring("test-lua_load"), lua.to_luastring("binary")); + lua.lua_load(L, function(L, s) { let r = s.bc; s.bc = null; return r; }, {bc: bc}, to_luastring("test-lua_load"), to_luastring("binary")); lua.lua_call(L, 0, 1); @@ -420,10 +421,10 @@ test('lua script reads js upvalues', function (t) { L = lauxlib.luaL_newstate(); - lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode)); + lauxlib.luaL_loadstring(L, to_luastring(luaCode)); lua.lua_pushliteral(L, "hello"); - lua.lua_setglobal(L, lua.to_luastring("js")); + lua.lua_setglobal(L, to_luastring("js")); lua.lua_call(L, 0, 1); @@ -518,7 +519,7 @@ test('lua_atnativeerror', function(t) { lua.lua_atnativeerror(L, function(L) { let e = lua.lua_touserdata(L, 1); t.strictEqual(e, errob); - lua.lua_pushstring(L, lua.to_luastring("runtime error!")); + lua.lua_pushstring(L, to_luastring("runtime error!")); return 1; }); lua.lua_pushcfunction(L, function(L) { @@ -532,7 +533,7 @@ test('lua_atnativeerror', function(t) { lua.lua_atnativeerror(L, function(L) { let e = lua.lua_touserdata(L, 1); t.strictEqual(e, errob); - lauxlib.luaL_error(L, lua.to_luastring("runtime error!")); + lauxlib.luaL_error(L, to_luastring("runtime error!")); }); lua.lua_pushcfunction(L, function(L) { throw errob; -- cgit v1.2.3-54-g00ecf