aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/defs.js14
-rw-r--r--tests/lapi.js15
-rw-r--r--tests/lauxlib.js9
-rw-r--r--tests/lbaselib.js35
-rw-r--r--tests/lcorolib.js12
-rw-r--r--tests/ldblib.js28
-rw-r--r--tests/ldebug.js15
-rw-r--r--tests/lexparse.js117
-rw-r--r--tests/lmathlib.js28
-rw-r--r--tests/load.js14
-rw-r--r--tests/loadlib.js10
-rw-r--r--tests/loslib.js12
-rw-r--r--tests/lstrlib.js46
-rw-r--r--tests/ltablib.js18
-rw-r--r--tests/ltm.js36
-rw-r--r--tests/lua.js15
-rw-r--r--tests/lutf8lib.js11
-rw-r--r--tests/lvm.js5
-rwxr-xr-xtests/manual-tests/debug-cli.js3
-rw-r--r--tests/test-suite/api.js215
-rw-r--r--tests/test-suite/attrib.js26
-rw-r--r--tests/test-suite/bitwise.js34
-rw-r--r--tests/test-suite/calls.js68
-rw-r--r--tests/test-suite/closure.js33
-rw-r--r--tests/test-suite/code.js62
-rw-r--r--tests/test-suite/constructs.js14
-rw-r--r--tests/test-suite/coroutine.js143
-rw-r--r--tests/test-suite/db.js60
-rw-r--r--tests/test-suite/errors.js144
-rw-r--r--tests/test-suite/events.js58
-rw-r--r--tests/test-suite/goto.js26
-rw-r--r--tests/test-suite/literals.js62
-rw-r--r--tests/test-suite/locals.js26
-rw-r--r--tests/test-suite/ltests.js63
-rw-r--r--tests/test-suite/math.js142
-rw-r--r--tests/test-suite/nextvar.js110
-rw-r--r--tests/test-suite/pm.js70
-rw-r--r--tests/test-suite/sort.js56
-rw-r--r--tests/test-suite/strings.js38
-rw-r--r--tests/test-suite/tpack.js40
-rw-r--r--tests/test-suite/utf8.js123
-rw-r--r--tests/test-suite/vararg.js18
-rw-r--r--tests/tests.js3
43 files changed, 1032 insertions, 1045 deletions
diff --git a/tests/defs.js b/tests/defs.js
index 1a935d6..f24dee0 100644
--- a/tests/defs.js
+++ b/tests/defs.js
@@ -6,37 +6,37 @@ const unicode_tests = [
{
description: "Convert normal ascii string",
literal: "foo",
- byte_array: defs.string_of("f".charCodeAt(0), "o".charCodeAt(0), "o".charCodeAt(0))
+ byte_array: defs.luastring_of("f".charCodeAt(0), "o".charCodeAt(0), "o".charCodeAt(0))
},
{
description: "Convert ascii string containing null byte",
literal: "fo\0o",
- byte_array: defs.string_of("f".charCodeAt(0), "o".charCodeAt(0), 0, "o".charCodeAt(0))
+ byte_array: defs.luastring_of("f".charCodeAt(0), "o".charCodeAt(0), 0, "o".charCodeAt(0))
},
{
description: "Convert string with BMP unicode chars",
literal: "Café",
- byte_array: defs.string_of(67, 97, 102, 195, 169)
+ byte_array: defs.luastring_of(67, 97, 102, 195, 169)
},
{
description: "Convert string with codepoint in PUA (U+E000 to U+F8FF)",
literal: "",
- byte_array: defs.string_of(239, 163, 191)
+ byte_array: defs.luastring_of(239, 163, 191)
},
{
description: "Convert string with surrogate pair",
literal: "❤️🍾",
- byte_array: defs.string_of(226, 157, 164, 239, 184, 143, 240, 159, 141, 190)
+ byte_array: defs.luastring_of(226, 157, 164, 239, 184, 143, 240, 159, 141, 190)
},
{
description: "Convert string with broken surrogate pair",
literal: "\uD800a",
- byte_array: defs.string_of(237, 160, 128, 97)
+ byte_array: defs.luastring_of(237, 160, 128, 97)
},
{
description: "Convert string with broken surrogate pair at end of string",
literal: "\uD823",
- byte_array: defs.string_of(237, 160, 163)
+ byte_array: defs.luastring_of(237, 160, 163)
}
];
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;
diff --git a/tests/lauxlib.js b/tests/lauxlib.js
index d484edb..8d57ecb 100644
--- a/tests/lauxlib.js
+++ b/tests/lauxlib.js
@@ -1,9 +1,10 @@
"use strict";
-const test = require('tape');
+const test = require('tape');
-const lua = require('../src/lua.js');
-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_ref, lua_rawgeti, luaL_unref, LUA_REGISTRYINDEX', function (t) {
let L;
@@ -12,7 +13,7 @@ test('luaL_ref, lua_rawgeti, luaL_unref, LUA_REGISTRYINDEX', function (t) {
t.doesNotThrow(function () {
L = lauxlib.luaL_newstate();
- lua.lua_pushstring(L, lua.to_luastring("hello references!"));
+ lua.lua_pushstring(L, to_luastring("hello references!"));
let r = lauxlib.luaL_ref(L, lua.LUA_REGISTRYINDEX); // pops a value, stores it and returns a reference
lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, r); // pushes a value associated with the reference
diff --git a/tests/lbaselib.js b/tests/lbaselib.js
index 6558c1f..6bef0d8 100644
--- a/tests/lbaselib.js
+++ b/tests/lbaselib.js
@@ -5,6 +5,7 @@ const test = require('tape');
const lua = require('../src/lua.js');
const lauxlib = require('../src/lauxlib.js');
const lualib = require('../src/lualib.js');
+const {to_luastring} = require("../src/fengaricore.js");
test('print', function (t) {
@@ -20,7 +21,7 @@ test('print', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -52,7 +53,7 @@ test('setmetatable, getmetatable', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -95,7 +96,7 @@ test('rawequal', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -139,7 +140,7 @@ test('rawset, rawget', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -184,7 +185,7 @@ test('type', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -235,7 +236,7 @@ test('error', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -256,7 +257,7 @@ test('error, protected', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_pcall(L, 0, -1, 0);
@@ -286,7 +287,7 @@ test('pcall', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -320,7 +321,7 @@ test('xpcall', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -358,7 +359,7 @@ test('ipairs', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -385,7 +386,7 @@ test('select', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -428,7 +429,7 @@ test('tonumber', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -478,7 +479,7 @@ test('assert', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_pcall(L, 0, -1, 0);
@@ -504,7 +505,7 @@ test('rawlen', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -549,7 +550,7 @@ test('next', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -588,7 +589,7 @@ test('pairs', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -636,7 +637,7 @@ test('pairs with __pairs', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
diff --git a/tests/lcorolib.js b/tests/lcorolib.js
index e1868b2..42f9677 100644
--- a/tests/lcorolib.js
+++ b/tests/lcorolib.js
@@ -6,7 +6,7 @@ const lua = require('../src/lua.js');
const lauxlib = require('../src/lauxlib.js');
const lualib = require('../src/lualib.js');
const lstate = require('../src/lstate.js');
-
+const {to_luastring} = require("../src/fengaricore.js");
test('coroutine.create, coroutine.yield, coroutine.resume', function (t) {
let luaCode = `
@@ -29,7 +29,7 @@ test('coroutine.create, coroutine.yield, coroutine.resume', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -70,7 +70,7 @@ test('coroutine.status', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -109,7 +109,7 @@ test('coroutine.isyieldable', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -148,7 +148,7 @@ test('coroutine.running', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -187,7 +187,7 @@ test('coroutine.wrap', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
diff --git a/tests/ldblib.js b/tests/ldblib.js
index 209e60e..8a30e48 100644
--- a/tests/ldblib.js
+++ b/tests/ldblib.js
@@ -5,7 +5,7 @@ const test = require('tape');
const lua = require('../src/lua.js');
const lauxlib = require('../src/lauxlib.js');
const lualib = require('../src/lualib.js');
-
+const {to_luastring} = require("../src/fengaricore.js");
test('debug.sethook', function (t) {
let luaCode = `
@@ -32,7 +32,7 @@ test('debug.sethook', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -75,7 +75,7 @@ test('debug.gethook', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -87,7 +87,7 @@ test('debug.gethook', function (t) {
t.deepEqual(
lua.lua_typename(L, lua.lua_type(L, -3)),
- lua.to_luastring("function"),
+ to_luastring("function"),
"Correct element(s) on the stack"
);
@@ -134,7 +134,7 @@ test('debug.getlocal', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -181,7 +181,7 @@ test('debug.setlocal', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -235,7 +235,7 @@ test('debug.upvalueid', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -278,7 +278,7 @@ test('debug.upvaluejoin', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -322,8 +322,8 @@ test('debug.traceback (with a global)', function (t) {
lualib.luaL_openlibs(L);
- luaCode = lua.to_luastring(luaCode);
- lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, lua.to_luastring("traceback-test"));
+ luaCode = to_luastring(luaCode);
+ lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring("traceback-test"));
}, "Lua program loaded without error");
@@ -379,8 +379,8 @@ test('debug.traceback (with a upvalue)', function (t) {
lualib.luaL_openlibs(L);
- luaCode = lua.to_luastring(luaCode);
- lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, lua.to_luastring("traceback-test"));
+ luaCode = to_luastring(luaCode);
+ lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring("traceback-test"));
}, "Lua program loaded without error");
@@ -431,8 +431,8 @@ test('debug.getinfo', function (t) {
lualib.luaL_openlibs(L);
- luaCode = lua.to_luastring(luaCode);
- lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, lua.to_luastring("getinfo-test"));
+ luaCode = to_luastring(luaCode);
+ lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring("getinfo-test"));
}, "Lua program loaded without error");
diff --git a/tests/ldebug.js b/tests/ldebug.js
index 857345e..49474e9 100644
--- a/tests/ldebug.js
+++ b/tests/ldebug.js
@@ -5,6 +5,7 @@ const test = require('tape');
const lua = require('../src/lua.js');
const lauxlib = require('../src/lauxlib.js');
const lualib = require('../src/lualib.js');
+const {to_luastring} = require("../src/fengaricore.js");
test('luaG_typeerror', function (t) {
let luaCode = `
@@ -20,7 +21,7 @@ test('luaG_typeerror', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_pcall(L, 0, -1, 0);
@@ -48,7 +49,7 @@ test('luaG_typeerror', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_pcall(L, 0, -1, 0);
@@ -75,7 +76,7 @@ test('luaG_typeerror', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_pcall(L, 0, -1, 0);
@@ -102,7 +103,7 @@ test('luaG_typeerror', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_pcall(L, 0, -1, 0);
@@ -128,7 +129,7 @@ test('luaG_concaterror', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_pcall(L, 0, -1, 0);
@@ -154,7 +155,7 @@ test('luaG_opinterror', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_pcall(L, 0, -1, 0);
@@ -180,7 +181,7 @@ test('luaG_tointerror', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_pcall(L, 0, -1, 0);
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");
diff --git a/tests/lmathlib.js b/tests/lmathlib.js
index a06812c..b50c59c 100644
--- a/tests/lmathlib.js
+++ b/tests/lmathlib.js
@@ -5,7 +5,7 @@ const test = require('tape');
const lua = require('../src/lua.js');
const lauxlib = require('../src/lauxlib.js');
const lualib = require('../src/lualib.js');
-
+const {to_luastring} = require("../src/fengaricore.js");
test('math.abs, math.sin, math.cos, math.tan, math.asin, math.acos, math.atan', function (t) {
let luaCode = `
@@ -21,7 +21,7 @@ test('math.abs, math.sin, math.cos, math.tan, math.asin, math.acos, math.atan',
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -84,7 +84,7 @@ test('math.ceil, math.floor', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -117,7 +117,7 @@ test('math.deg, math.rad', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -150,7 +150,7 @@ test('math.log', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -189,7 +189,7 @@ test('math.exp', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -216,7 +216,7 @@ test('math.min, math.max', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -249,7 +249,7 @@ test('math.random', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -280,7 +280,7 @@ test('math.sqrt', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -307,7 +307,7 @@ test('math.tointeger', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -334,7 +334,7 @@ test('math.type', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -373,7 +373,7 @@ test('math.ult', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -400,7 +400,7 @@ test('math.fmod', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -427,7 +427,7 @@ test('math.modf', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
diff --git a/tests/load.js b/tests/load.js
index 49756a5..8555014 100644
--- a/tests/load.js
+++ b/tests/load.js
@@ -8,7 +8,7 @@ const toByteCode = tests.toByteCode;
const lua = require('../src/lua.js');
const lauxlib = require('../src/lauxlib.js');
const lualib = require('../src/lualib.js');
-
+const {to_luastring} = require("../src/fengaricore.js");
test('luaL_loadstring', function (t) {
let luaCode = `
@@ -24,7 +24,7 @@ test('luaL_loadstring', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -56,7 +56,7 @@ test('load', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -90,7 +90,7 @@ test('luaL_loadbuffer', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadbuffer(L, bc, null, lua.to_luastring("test"));
+ lauxlib.luaL_loadbuffer(L, bc, null, to_luastring("test"));
}, "Lua program loaded without error");
@@ -122,7 +122,7 @@ test('loadfile', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -154,7 +154,7 @@ test('loadfile (binary)', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -185,7 +185,7 @@ test('dofile', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
diff --git a/tests/loadlib.js b/tests/loadlib.js
index c4c98ea..dba2a3a 100644
--- a/tests/loadlib.js
+++ b/tests/loadlib.js
@@ -5,7 +5,7 @@ const test = require('tape');
const lua = require('../src/lua.js');
const lauxlib = require('../src/lauxlib.js');
const lualib = require('../src/lualib.js');
-
+const {to_luastring} = require("../src/fengaricore.js");
test('require an existing module', function (t) {
let luaCode = `
@@ -20,7 +20,7 @@ test('require an existing module', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -50,7 +50,7 @@ test('require a file', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -81,7 +81,7 @@ test('package.loadlib', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -112,7 +112,7 @@ test('package.searchpath', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
diff --git a/tests/loslib.js b/tests/loslib.js
index 83d6c81..904ca9c 100644
--- a/tests/loslib.js
+++ b/tests/loslib.js
@@ -5,7 +5,7 @@ const test = require('tape');
const lua = require('../src/lua.js');
const lauxlib = require('../src/lauxlib.js');
const lualib = require('../src/lualib.js');
-
+const {to_luastring} = require("../src/fengaricore.js");
test('os.time', function (t) {
let luaCode = `
@@ -20,7 +20,7 @@ test('os.time', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -54,7 +54,7 @@ test('os.time (with format)', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -87,7 +87,7 @@ test('os.difftime', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -121,7 +121,7 @@ test('os.date', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -152,7 +152,7 @@ test('os.getenv', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
diff --git a/tests/lstrlib.js b/tests/lstrlib.js
index bdf68d8..50e9996 100644
--- a/tests/lstrlib.js
+++ b/tests/lstrlib.js
@@ -5,7 +5,7 @@ const test = require('tape');
const lua = require('../src/lua.js');
const lauxlib = require('../src/lauxlib.js');
const lualib = require('../src/lualib.js');
-
+const {to_luastring} = require("../src/fengaricore.js");
test('string.len', function (t) {
let luaCode = `
@@ -21,7 +21,7 @@ test('string.len', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -59,7 +59,7 @@ test('string.char', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -90,7 +90,7 @@ test('string.upper, string.lower', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -127,7 +127,7 @@ test('string.rep', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -158,7 +158,7 @@ test('string.reverse', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -189,7 +189,7 @@ test('string.byte', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -232,7 +232,7 @@ test('string.format', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -263,7 +263,7 @@ test('string.format', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -294,7 +294,7 @@ test('string.format', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -335,7 +335,7 @@ test('string.sub', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -434,7 +434,7 @@ test('string.dump', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode.trim()));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode.trim()));
}, "Lua program loaded without error");
@@ -444,7 +444,7 @@ test('string.dump', function (t) {
let str = lua.lua_tostring(L, -1);
- lua.lua_load(L, function(L, s) { let r = s.str; s.str = null; return r; }, {str: str}, lua.to_luastring("test"), lua.to_luastring("binary"));
+ lua.lua_load(L, function(L, s) { let r = s.str; s.str = null; return r; }, {str: str}, to_luastring("test"), to_luastring("binary"));
lua.lua_call(L, 0, -1);
@@ -474,7 +474,7 @@ test('string.pack/unpack/packsize', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -510,7 +510,7 @@ test('string.find without pattern', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -547,7 +547,7 @@ test('string.match', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -584,7 +584,7 @@ test('string.find', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -640,7 +640,7 @@ test('string.gmatch', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -689,7 +689,7 @@ test('string.gsub', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -726,7 +726,7 @@ test('string.gsub (number)', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -763,7 +763,7 @@ test('string.gsub (pattern)', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -802,7 +802,7 @@ test('string.gsub (function)', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -841,7 +841,7 @@ test('string.gsub (table)', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
diff --git a/tests/ltablib.js b/tests/ltablib.js
index 2adf1fe..660ac85 100644
--- a/tests/ltablib.js
+++ b/tests/ltablib.js
@@ -5,7 +5,7 @@ const test = require('tape');
const lua = require('../src/lua.js');
const lauxlib = require('../src/lauxlib.js');
const lualib = require('../src/lualib.js');
-
+const {to_luastring} = require("../src/fengaricore.js");
const inttable2array = function(t) {
let a = [];
@@ -31,7 +31,7 @@ test('table.concat', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -58,7 +58,7 @@ test('table.pack', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -87,7 +87,7 @@ test('table.unpack', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -129,7 +129,7 @@ test('table.insert', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -161,7 +161,7 @@ test('table.remove', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -192,7 +192,7 @@ test('table.move', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -223,7 +223,7 @@ test('table.sort (<)', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
@@ -254,7 +254,7 @@ test('table.sort with cmp function', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
diff --git a/tests/ltm.js b/tests/ltm.js
index 0d9bc1a..156d63b 100644
--- a/tests/ltm.js
+++ b/tests/ltm.js
@@ -5,7 +5,7 @@ const test = require('tape');
const lua = require('../src/lua.js');
const lauxlib = require('../src/lauxlib.js');
const lualib = require('../src/lualib.js');
-
+const {to_luastring} = require("../src/fengaricore.js");
test('__index, __newindex: with actual table', function (t) {
let luaCode = `
@@ -20,7 +20,7 @@ test('__index, __newindex: with actual table', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, -1);
}, "Program executed without errors");
@@ -50,7 +50,7 @@ test('__newindex: with non table', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Bytecode parsed without errors");
t.throws(function () {
@@ -81,7 +81,7 @@ test('__index function in metatable', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Bytecode parsed without errors");
@@ -121,7 +121,7 @@ test('__newindex function in metatable', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -159,7 +159,7 @@ test('__index table in metatable', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -200,7 +200,7 @@ test('__newindex table in metatable', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -252,7 +252,7 @@ test('__index table with own metatable', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -303,7 +303,7 @@ test('__newindex table with own metatable', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -402,7 +402,7 @@ test('binary __xxx functions in metatable', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -452,7 +452,7 @@ test('__eq', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -488,7 +488,7 @@ test('__lt', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -524,7 +524,7 @@ test('__le', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -560,7 +560,7 @@ test('__le that uses __lt', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -600,7 +600,7 @@ test('__unm, __bnot', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -643,7 +643,7 @@ test('__len', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -680,7 +680,7 @@ test('__concat', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -717,7 +717,7 @@ test('__call', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
diff --git a/tests/lua.js b/tests/lua.js
index 82df6ff..0d9cf2e 100644
--- a/tests/lua.js
+++ b/tests/lua.js
@@ -5,8 +5,7 @@ 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 {to_luastring} = require("../src/fengaricore.js");
// TODO: remove
test.skip('locals.lua', function (t) {
@@ -24,13 +23,13 @@ test.skip('locals.lua', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
});
@@ -51,13 +50,13 @@ test.skip('constructs.lua', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
});
@@ -76,13 +75,13 @@ test.skip('strings.lua', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
- lapi.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
}, "Lua program ran without error");
});
diff --git a/tests/lutf8lib.js b/tests/lutf8lib.js
index ae40d3c..baccceb 100644
--- a/tests/lutf8lib.js
+++ b/tests/lutf8lib.js
@@ -5,6 +5,7 @@ const test = require('tape');
const lua = require("../src/lua.js");
const lauxlib = require("../src/lauxlib.js");
const lualib = require("../src/lualib.js");
+const {to_luastring} = require("../src/fengaricore.js");
test('utf8.offset', function (t) {
let luaCode = `
@@ -19,7 +20,7 @@ test('utf8.offset', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -50,7 +51,7 @@ test('utf8.codepoint', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -93,7 +94,7 @@ test('utf8.char', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -124,7 +125,7 @@ test('utf8.len', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -160,7 +161,7 @@ test('utf8.codes', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
diff --git a/tests/lvm.js b/tests/lvm.js
index 08c0c5e..7fba553 100644
--- a/tests/lvm.js
+++ b/tests/lvm.js
@@ -4,6 +4,7 @@ const test = require('tape');
const lua = require("../src/lua.js");
const lstring = require("../src/lstring.js");
+const {to_luastring} = require("../src/fengaricore.js");
const getState = require("./tests.js").getState;
@@ -459,7 +460,7 @@ test('SETTABLE, GETTABLE', function (t) {
);
t.deepEqual(
- L.stack[L.top - 1].value.strong.get(lstring.luaS_hash(lua.to_luastring("two"))).value.jsstring(), // "two"
+ L.stack[L.top - 1].value.strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring(), // "two"
"world",
"Program output is correct"
);
@@ -518,7 +519,7 @@ test('SETTABUP, GETTABUP', function (t) {
);
t.deepEqual(
- L.stack[L.top - 1].value.strong.get(lstring.luaS_hash(lua.to_luastring("two"))).value.jsstring(), // "two"
+ L.stack[L.top - 1].value.strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring(), // "two"
"world", // "world"
"Program output is correct"
);
diff --git a/tests/manual-tests/debug-cli.js b/tests/manual-tests/debug-cli.js
index 3feb981..dc49a0e 100755
--- a/tests/manual-tests/debug-cli.js
+++ b/tests/manual-tests/debug-cli.js
@@ -4,6 +4,7 @@
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
const lualib = require('../../src/lualib.js');
+const {to_luastring} = require("../../src/fengaricore.js");
let luaCode = `
a = "debug me"
@@ -14,6 +15,6 @@ L = lauxlib.luaL_newstate();
lualib.luaL_openlibs(L);
-lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+lauxlib.luaL_loadstring(L, to_luastring(luaCode));
lua.lua_call(L, 0, 0);
diff --git a/tests/test-suite/api.js b/tests/test-suite/api.js
index b5f45c3..0061c88 100644
--- a/tests/test-suite/api.js
+++ b/tests/test-suite/api.js
@@ -5,6 +5,7 @@ const test = require('tape');
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
const lualib = require('../../src/lualib.js');
+const {to_luastring} = require("../../src/fengaricore.js");
const ltests = require('./ltests.js');
@@ -32,7 +33,7 @@ test("[test-suite] api: registry", function (t) {
a = T.testC("pushvalue R; return 1")
assert(a == debug.getregistry())
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -43,7 +44,7 @@ test("[test-suite] api: registry", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -62,7 +63,7 @@ test("[test-suite] api: absindex", function (t) {
assert(T.testC("settop 10; absindex 1; return 1") == 1)
assert(T.testC("settop 10; absindex R; return 1") < -10)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -73,7 +74,7 @@ test("[test-suite] api: absindex", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -99,7 +100,7 @@ test("[test-suite] api: testing alignment", function (t) {
a,b,c = f()
assert(a == 2 and b == 3 and not c)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -110,7 +111,7 @@ test("[test-suite] api: testing alignment", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -164,7 +165,7 @@ test("[test-suite] api: test that all trues are equal", function (t) {
t = pack(T.testC("copy -3 -1; return *", 2, 3, 4, 5))
tcheck(t, {n=4,2,3,4,3})
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -175,7 +176,7 @@ test("[test-suite] api: test that all trues are equal", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -212,7 +213,7 @@ test("[test-suite] api: testing 'rotate'", function (t) {
tcheck(t, {10, 20, 30, 40})
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -223,7 +224,7 @@ test("[test-suite] api: testing 'rotate'", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -265,7 +266,7 @@ test("[test-suite] api: testing non-function message handlers", function (t) {
t = pack(T.testC("concat 5; return *", "alo", 2, 3, "joao", 12))
tcheck(t, {n=1,"alo23joao12"})
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -276,7 +277,7 @@ test("[test-suite] api: testing non-function message handlers", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -294,7 +295,7 @@ test("[test-suite] api: testing MULTRET", function (t) {
function (a,b) return 1,2,3,4,a,b end, "alo", "joao"))
tcheck(t, {n=6,1,2,3,4,"alo", "joao"})
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -305,7 +306,7 @@ test("[test-suite] api: testing MULTRET", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -327,7 +328,7 @@ test("[test-suite] api: test returning more results than fit in the caller stack
assert(b == "10")
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -338,7 +339,7 @@ test("[test-suite] api: test returning more results than fit in the caller stack
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -362,7 +363,7 @@ test("[test-suite] api: testing globals", function (t) {
]]}
assert(a[2] == 14 and a[3] == "a31" and a[4] == nil and _G.a == "a31")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -373,7 +374,7 @@ test("[test-suite] api: testing globals", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -420,7 +421,7 @@ test("[test-suite] api: testing arith", function (t) {
assert(T.testC("arith _; arith +; arith %; return 1", b, a, c)[1] ==
8 % (4 + (-3)*2))
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -431,7 +432,7 @@ test("[test-suite] api: testing arith", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -448,7 +449,7 @@ test("[test-suite] api: errors in arithmetic", function (t) {
checkerr("divide by zero", T.testC, "arith \\\\", 10, 0)
checkerr("%%0", T.testC, "arith %", 10, 0)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -459,7 +460,7 @@ test("[test-suite] api: errors in arithmetic", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -481,7 +482,7 @@ test("[test-suite] api: testing lessthan and lessequal", function (t) {
assert(not T.testC("compare LT 2 -3, return 1", "4", "2", "2", "3", "2", "2"))
assert(not T.testC("compare LT -3 2, return 1", "3", "2", "2", "4", "2", "2"))
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -492,7 +493,7 @@ test("[test-suite] api: testing lessthan and lessequal", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -524,7 +525,7 @@ test("[test-suite] api: non-valid indices produce false", function (t) {
a,b = T.testC("compare LE 5 -6, return 2", a1, 2, 2, a1, 2, 20)
assert(a == 20 and b == true)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -535,7 +536,7 @@ test("[test-suite] api: non-valid indices produce false", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -575,7 +576,7 @@ test("[test-suite] api: testing length", function (t) {
]], t)
assert(a == print and c == 1)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -586,7 +587,7 @@ test("[test-suite] api: testing length", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -617,7 +618,7 @@ test("[test-suite] api: testing __concat", function (t) {
-- concat with 1 element
assert(T.testC("concat 1; return 1", "xuxu") == "xuxu")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -628,7 +629,7 @@ test("[test-suite] api: testing __concat", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -672,7 +673,7 @@ test("[test-suite] api: testing lua_is", function (t) {
assert(count(io.stdin) == 1)
assert(count(nil, 15) == 100)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -683,7 +684,7 @@ test("[test-suite] api: testing lua_is", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -733,7 +734,7 @@ test("[test-suite] api: testing lua_to...", function (t) {
a = to("tocfunction", math.deg)
assert(a(3) == math.deg(3) and a == math.deg)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -744,7 +745,7 @@ test("[test-suite] api: testing lua_to...", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -771,7 +772,7 @@ test("[test-suite] api: testing panic function", function (t) {
-- "argerror" without frames
assert(T.checkpanic("loadstring 4") ==
"bad argument #4 (string expected, got no value)")
-
+
--[[ TODO: T.totalmem
-- memory error
@@ -792,7 +793,7 @@ test("[test-suite] api: testing panic function", function (t) {
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -803,7 +804,7 @@ test("[test-suite] api: testing panic function", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -848,7 +849,7 @@ test("[test-suite] api: testing deep JS stack", { skip: true }, function (t) {
assert(next(t) == nil)
prog, g, t = nil
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -859,7 +860,7 @@ test("[test-suite] api: testing deep JS stack", { skip: true }, function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -891,7 +892,7 @@ test("[test-suite] api: testing errors", function (t) {
check3("%.", T.testC("loadfile 2; return *", "."))
check3("xxxx", T.testC("loadfile 2; return *", "xxxx"))
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -902,7 +903,7 @@ test("[test-suite] api: testing errors", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -929,7 +930,7 @@ test("[test-suite] api: test errors in non protected threads", { skip: true }, f
checkerrnopro("getglobal 'f'; call 0 0;", "stack overflow")
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -940,7 +941,7 @@ test("[test-suite] api: test errors in non protected threads", { skip: true }, f
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -992,7 +993,7 @@ test("[test-suite] api: testing table access", function (t) {
assert(a[b] == 19)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1003,7 +1004,7 @@ test("[test-suite] api: testing table access", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1032,7 +1033,7 @@ test("[test-suite] api: testing getfield/setfield with long keys", function (t)
_012345678901234567890123456789012345678901234567890123456789 = nil
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1043,7 +1044,7 @@ test("[test-suite] api: testing getfield/setfield with long keys", function (t)
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1066,7 +1067,7 @@ test("[test-suite] api: testing next", function (t) {
t = pack(T.testC("next; pop 1; next; return *", a, nil))
tcheck(t, {n=1,a})
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1077,7 +1078,7 @@ test("[test-suite] api: testing next", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1106,7 +1107,7 @@ test("[test-suite] api: testing upvalues", function (t) {
-- T.checkmemory()
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1117,7 +1118,7 @@ test("[test-suite] api: testing upvalues", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1142,7 +1143,7 @@ test("[test-suite] api: testing absent upvalues from JS-function pointers", func
T.upvalue(f, 2, "xuxu")
assert(T.upvalue(f, 2) == "xuxu")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1153,7 +1154,7 @@ test("[test-suite] api: testing absent upvalues from JS-function pointers", func
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1179,7 +1180,7 @@ test("[test-suite] api: large closures", function (t) {
assert(not A("isnil U256; return 1"))
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1190,7 +1191,7 @@ test("[test-suite] api: large closures", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1226,7 +1227,7 @@ test("[test-suite] api: testing get/setuservalue", function (t) {
-- collectgarbage() -- number should not be a problem for collector
assert(debug.getuservalue(b) == 134)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1237,7 +1238,7 @@ test("[test-suite] api: testing get/setuservalue", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1257,7 +1258,7 @@ test("[test-suite] api: testing get/setuservalue", { skip: true }, function (t)
T.gcstate("pause") -- complete collection
assert(debug.getuservalue(b).x == 100) -- uvalue should be there
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1268,7 +1269,7 @@ test("[test-suite] api: testing get/setuservalue", { skip: true }, function (t)
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1294,7 +1295,7 @@ test("[test-suite] api: long chain of userdata", { skip: true }, function (t) {
assert(debug.getuservalue(b).x == 100)
b = nil
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1305,7 +1306,7 @@ test("[test-suite] api: long chain of userdata", { skip: true }, function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1366,7 +1367,7 @@ test("[test-suite] api: reuse of references", { skip: true }, function (t) {
assert(type(T.getref(a)) == 'table')
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1377,7 +1378,7 @@ test("[test-suite] api: reuse of references", { skip: true }, function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1494,7 +1495,7 @@ test("[test-suite] api: collect in cl the `val' of all collected userdata", { sk
collectgarbage()
assert(#cl == 1 and cl[1] == x) -- old 'x' must be collected
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1505,7 +1506,7 @@ test("[test-suite] api: collect in cl the `val' of all collected userdata", { sk
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1550,7 +1551,7 @@ test("[test-suite] api: test whether udate collection frees memory in the right
collectgarbage("restart")
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1561,7 +1562,7 @@ test("[test-suite] api: test whether udate collection frees memory in the right
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1582,7 +1583,7 @@ test("[test-suite] api: testing lua_equal", function (t) {
assert(not T.testC("compare EQ 2 3; return 1"))
assert(not T.testC("compare EQ 2 3; return 1", 3))
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1593,7 +1594,7 @@ test("[test-suite] api: testing lua_equal", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1624,7 +1625,7 @@ test("[test-suite] api: testing lua_equal with fallbacks", function (t) {
assert(f(10) ~= f(10))
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1635,7 +1636,7 @@ test("[test-suite] api: testing lua_equal with fallbacks", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1670,7 +1671,7 @@ test("[test-suite] api: testing changing hooks during hooks", function (t) {
assert(t[5] == "line" and t[6] == line + 2)
assert(t[7] == nil)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1681,7 +1682,7 @@ test("[test-suite] api: testing changing hooks during hooks", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1722,7 +1723,7 @@ test("[test-suite] api: testing errors during GC", { skip: true }, function (t)
assert(A == 10) -- number of normal collections
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1733,7 +1734,7 @@ test("[test-suite] api: testing errors during GC", { skip: true }, function (t)
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1757,7 +1758,7 @@ test("[test-suite] api: test for userdata vals", function (t) {
assert(type(tostring(a[1])) == "string")
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1768,7 +1769,7 @@ test("[test-suite] api: test for userdata vals", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1828,7 +1829,7 @@ test("[test-suite] api: testing multiple states", function (t) {
T.closestate(L1)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1839,7 +1840,7 @@ test("[test-suite] api: testing multiple states", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1859,7 +1860,7 @@ test("[test-suite] api: testing memory limits", { skip: true }, function (t) {
checkerr("not enough memory", load"local a={}; for i=1,100000 do a[i]=i end")
T.totalmem(0) -- restore high limit
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1870,7 +1871,7 @@ test("[test-suite] api: testing memory limits", { skip: true }, function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1914,7 +1915,7 @@ test("[test-suite] api: testing memory errors when creating a new state", { skip
b = testamem("state creation", T.newstate)
T.closestate(b); -- close new state
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1925,7 +1926,7 @@ test("[test-suite] api: testing memory errors when creating a new state", { skip
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + memprefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode));
}, "Lua program loaded without error");
@@ -1936,13 +1937,35 @@ test("[test-suite] api: testing memory errors when creating a new state", { skip
}, "Lua program ran without error");
});
-test("[test-suite] api: get main thread from registry (at index LUA_RIDX_MAINTHREAD == 1)", { skip: true }, function (t) {
+test("[test-suite] api: get main thread from registry (at index LUA_RIDX_MAINTHREAD == 1)", function (t) {
let luaCode = `
mt = T.testC("rawgeti R 1; return 1")
assert(type(mt) == "thread" and coroutine.running() == mt)
+ `, L;
+
+ t.plan(2);
+
+ t.doesNotThrow(function () {
+
+ L = lauxlib.luaL_newstate();
+
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode));
+ }, "Lua program loaded without error");
+
+ t.doesNotThrow(function () {
+ lua.lua_call(L, 0, -1);
+
+ }, "Lua program ran without error");
+});
+
+test("[test-suite] api: test thread creation after stressing GC", { skip: true }, function (t) {
+ let luaCode = `
function expand (n,s)
if n==0 then return "" end
local e = string.rep("=", n)
@@ -1958,7 +1981,7 @@ test("[test-suite] api: get main thread from registry (at index LUA_RIDX_MAINTHR
return T.doonnewstack("x=1") == 0 -- try to create thread
end)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1969,7 +1992,7 @@ test("[test-suite] api: get main thread from registry (at index LUA_RIDX_MAINTHR
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + memprefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode));
}, "Lua program loaded without error");
@@ -1987,7 +2010,7 @@ test("[test-suite] api: testing memory x compiler", { skip: true }, function (t)
return load("x=1") -- try to do load a string
end)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1998,7 +2021,7 @@ test("[test-suite] api: testing memory x compiler", { skip: true }, function (t)
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + memprefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode));
}, "Lua program loaded without error");
@@ -2033,7 +2056,7 @@ test("[test-suite] api: testing memory x dofile", { skip: true }, function (t) {
assert(os.remove(t))
assert(_G.a == "aaax")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -2044,7 +2067,7 @@ test("[test-suite] api: testing memory x dofile", { skip: true }, function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + memprefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode));
}, "Lua program loaded without error");
@@ -2116,7 +2139,7 @@ test("[test-suite] api: other generic tests", { skip: true }, function (t) {
end)
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -2127,7 +2150,7 @@ test("[test-suite] api: other generic tests", { skip: true }, function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + memprefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode));
}, "Lua program loaded without error");
@@ -2153,7 +2176,7 @@ test("[test-suite] api: testing some auxlib functions", function (t) {
assert(gsub("...", ".", "/.") == "/././.")
assert(gsub("...", "...", "") == "")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -2164,7 +2187,7 @@ test("[test-suite] api: testing some auxlib functions", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -2225,7 +2248,7 @@ test("[test-suite] api: testing luaL_newmetatable", function (t) {
r.xuxu = nil; r.xuxu1 = nil
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -2236,7 +2259,7 @@ test("[test-suite] api: testing luaL_newmetatable", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
diff --git a/tests/test-suite/attrib.js b/tests/test-suite/attrib.js
index fcd3271..7445a5e 100644
--- a/tests/test-suite/attrib.js
+++ b/tests/test-suite/attrib.js
@@ -5,7 +5,7 @@ const test = require('tape');
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
const lualib = require('../../src/lualib.js');
-
+const {to_luastring} = require("../../src/fengaricore.js");
test("[test-suite] attrib: testing require", function (t) {
let luaCode = `
@@ -53,7 +53,7 @@ test("[test-suite] attrib: testing require", function (t) {
package.path = oldpath
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -62,7 +62,7 @@ test("[test-suite] attrib: testing require", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -169,7 +169,7 @@ test("[test-suite] attrib: testing assignments, logical operators, and construct
a[1], f(a)[2], b, c = {['alo']=assert}, 10, a[1], a[f], 6, 10, 23, f(a), 2
a[1].alo(a[2]==10 and b==10 and c==print)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -178,7 +178,7 @@ test("[test-suite] attrib: testing assignments, logical operators, and construct
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -245,7 +245,7 @@ test("[test-suite] attrib: test of large float/integer indices ", function (t) {
assert(a[maxintF] == 20 and a[maxintF - 1.0] == 11 and
a[-maxintF] == 22 and a[-maxintF + 1.0] == 13)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -254,7 +254,7 @@ test("[test-suite] attrib: test of large float/integer indices ", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -277,7 +277,7 @@ test("[test-suite] attrib: test conflicts in multiple assignment", function (t)
b[3] == 1)
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -286,7 +286,7 @@ test("[test-suite] attrib: test conflicts in multiple assignment", function (t)
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -315,7 +315,7 @@ test("[test-suite] attrib: repeat test with upvalues", function (t) {
assert(t[1] == 10)
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -324,7 +324,7 @@ test("[test-suite] attrib: repeat test with upvalues", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -351,7 +351,7 @@ test("[test-suite] attrib: bug in 5.2 beta", function (t) {
local a, b = foo()()
assert(a == 3 and b == 14)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -360,7 +360,7 @@ test("[test-suite] attrib: bug in 5.2 beta", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
diff --git a/tests/test-suite/bitwise.js b/tests/test-suite/bitwise.js
index df57f15..17e3c84 100644
--- a/tests/test-suite/bitwise.js
+++ b/tests/test-suite/bitwise.js
@@ -5,7 +5,7 @@ const test = require('tape');
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
const lualib = require('../../src/lualib.js');
-
+const {to_luastring} = require("../../src/fengaricore.js");
const prefix = `
package.preload.bit32 = function () --{
@@ -176,7 +176,7 @@ test("[test-suite] bitwise: testing bitwise operations", function (t) {
-- embedded zeros
assert(not pcall(function () return "0xffffffffffffffff\\0" | 0 end))
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -185,7 +185,7 @@ test("[test-suite] bitwise: testing bitwise operations", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -208,7 +208,7 @@ test("[test-suite] bitwise: testing bitwise library", function (t) {
assert(bit32.band() == bit32.band(0xffffffff))
assert(bit32.band(1,2) == 0)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -217,7 +217,7 @@ test("[test-suite] bitwise: testing bitwise library", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -285,7 +285,7 @@ test("[test-suite] bitwise: out-of-range numbers", function (t) {
assert(0x12345678 >> 32 == 0)
assert(0x12345678 >> -32 == 0x1234567800000000)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -294,7 +294,7 @@ test("[test-suite] bitwise: out-of-range numbers", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -340,7 +340,7 @@ test("[test-suite] bitwise: some special cases", function (t) {
assert(bit32.rshift(bit32.rshift(b, 4), -4) == bit32.band(b, bit32.bnot(0xf)))
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -349,7 +349,7 @@ test("[test-suite] bitwise: some special cases", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -379,7 +379,7 @@ test("[test-suite] bitwise: for this test, use at most 24 bits (mantissa of a si
assert(not pcall(bit32.lshift, 45, print))
assert(not pcall(bit32.rshift, 45, print))
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -388,7 +388,7 @@ test("[test-suite] bitwise: for this test, use at most 24 bits (mantissa of a si
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -422,7 +422,7 @@ test("[test-suite] bitwise: testing extract/replace", function (t) {
assert(bit32.replace(-1, 0, 31) == (1 << 31) - 1)
assert(bit32.replace(-1, 0, 1, 2) == (1 << 32) - 7)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -431,7 +431,7 @@ test("[test-suite] bitwise: testing extract/replace", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -449,7 +449,7 @@ test("[test-suite] bitwise: testing conversion of floats", function (t) {
assert(bit32.bor(3.0) == 3)
assert(bit32.bor(-4.0) == 0xfffffffc)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -458,7 +458,7 @@ test("[test-suite] bitwise: testing conversion of floats", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -480,7 +480,7 @@ test("[test-suite] bitwise: large floats and large-enough integers?", function (
assert(bit32.bor(-2.0^48 - 6.0) == 0xfffffffa)
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -489,7 +489,7 @@ test("[test-suite] bitwise: large floats and large-enough integers?", function (
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
diff --git a/tests/test-suite/calls.js b/tests/test-suite/calls.js
index fdd5eac..2044e5c 100644
--- a/tests/test-suite/calls.js
+++ b/tests/test-suite/calls.js
@@ -5,7 +5,7 @@ const test = require('tape');
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
const lualib = require('../../src/lualib.js');
-
+const {to_luastring} = require("../../src/fengaricore.js");
test("[test-suite] calls: test 'type'", function (t) {
let luaCode = `
@@ -22,7 +22,7 @@ test("[test-suite] calls: test 'type'", function (t) {
assert(type(f) == 'function')
assert(not pcall(type))
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -31,7 +31,7 @@ test("[test-suite] calls: test 'type'", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -56,11 +56,11 @@ test("[test-suite] calls: test error in 'print'", function (t) {
_ENV.tostring = function () return {} end
local st, msg = pcall(print, 1)
assert(st == false and string.find(msg, "must return a string"))
-
+
_ENV.tostring = tostring
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -69,7 +69,7 @@ test("[test-suite] calls: test error in 'print'", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -96,7 +96,7 @@ test("[test-suite] calls: testing local-function recursion", function (t) {
end
assert(fact == false)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -105,7 +105,7 @@ test("[test-suite] calls: testing local-function recursion", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -203,7 +203,7 @@ test("[test-suite] calls: testing declarations", function (t) {
(function (x) a=x end)(23)
assert(a == 23 and (function (x) return x*2 end)(20) == 40)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -212,7 +212,7 @@ test("[test-suite] calls: testing declarations", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -261,7 +261,7 @@ test("[test-suite] calls: testing closures", function (t) {
Z, F, f = nil
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -270,7 +270,7 @@ test("[test-suite] calls: testing closures", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -319,7 +319,7 @@ test("[test-suite] calls: testing multiple returns", function (t) {
a = ret2{ unlpack{1,2,3}, unlpack{3,2,1}, unlpack{"a", "b"}}
assert(a[1] == 1 and a[2] == 3 and a[3] == "a" and a[4] == "b")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -328,7 +328,7 @@ test("[test-suite] calls: testing multiple returns", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -348,7 +348,7 @@ test("[test-suite] calls: testing calls with 'incorrect' arguments", function (t
assert(math.sin(1,2) == math.sin(1))
table.sort({10,9,8,4,19,23,0,0}, function (a,b) return a<b end, "extra arg")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -357,7 +357,7 @@ test("[test-suite] calls: testing calls with 'incorrect' arguments", function (t
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -420,7 +420,7 @@ test("[test-suite] calls: test for generic load", function (t) {
cannotload("unexpected symbol", load("*a = 123"))
cannotload("hhi", load(function () error("hhi") end))
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -429,7 +429,7 @@ test("[test-suite] calls: test for generic load", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -446,7 +446,7 @@ test("[test-suite] calls: any value is valid for _ENV", function (t) {
let luaCode = `
assert(load("return _ENV", nil, nil, 123)() == 123)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -455,7 +455,7 @@ test("[test-suite] calls: any value is valid for _ENV", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -483,7 +483,7 @@ test("[test-suite] calls: load when _ENV is not first upvalue", function (t) {
assert(assert(load("return XX + ...", nil, nil, {XX = 13}))(4) == 17)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -492,7 +492,7 @@ test("[test-suite] calls: load when _ENV is not first upvalue", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -528,7 +528,7 @@ test("[test-suite] calls: test generic load with nested functions", function (t)
a = assert(load(read1(x)))
assert(a()(2)(3)(10) == 15)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -537,7 +537,7 @@ test("[test-suite] calls: test generic load with nested functions", function (t)
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -568,7 +568,7 @@ test("[test-suite] calls: test for dump/undump with upvalues", function (t) {
x("set")
assert(x() == 24)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -577,7 +577,7 @@ test("[test-suite] calls: test for dump/undump with upvalues", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -615,7 +615,7 @@ test("[test-suite] calls: test for dump/undump with many upvalues", function (t)
assert(f() == 10 * nup)
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -624,7 +624,7 @@ test("[test-suite] calls: test for dump/undump with many upvalues", function (t)
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -647,7 +647,7 @@ test("[test-suite] calls: test for long method names", function (t) {
assert(t:_012345678901234567890123456789012345678901234567890123456789() == 1)
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -656,7 +656,7 @@ test("[test-suite] calls: test for long method names", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -675,7 +675,7 @@ test("[test-suite] calls: test for bug in parameter adjustment", function (t) {
assert((function () local a; return a end)(4) == nil)
assert((function (a) return a end)() == nil)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -684,7 +684,7 @@ test("[test-suite] calls: test for bug in parameter adjustment", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -734,7 +734,7 @@ test("[test-suite] calls: testing binary chunks", function (t) {
assert(assert(load(c))() == 10)
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -743,7 +743,7 @@ test("[test-suite] calls: testing binary chunks", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
diff --git a/tests/test-suite/closure.js b/tests/test-suite/closure.js
index 464a5b5..79a2226 100644
--- a/tests/test-suite/closure.js
+++ b/tests/test-suite/closure.js
@@ -5,6 +5,7 @@ const test = require('tape');
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
const lualib = require('../../src/lualib.js');
+const {to_luastring} = require("../../src/fengaricore.js");
test("[test-suite] closure: testing equality", function (t) {
let luaCode = `
@@ -20,7 +21,7 @@ test("[test-suite] closure: testing equality", function (t) {
end
assert(f() == f())
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -29,7 +30,7 @@ test("[test-suite] closure: testing equality", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -73,7 +74,7 @@ test("[test-suite] closure: testing closures with 'for' control variable", funct
r,s = a[2].get()
assert(r == "a" and s == "b")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -82,7 +83,7 @@ test("[test-suite] closure: testing closures with 'for' control variable", funct
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -113,7 +114,7 @@ test("[test-suite] closure: testing closures with 'for' control variable x break
assert(({f()})[1] == 1)
assert(({f()})[2] == "a")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -122,7 +123,7 @@ test("[test-suite] closure: testing closures with 'for' control variable x break
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -169,7 +170,7 @@ test("[test-suite] closure: testing closure x break x return x errors", function
assert(b('get') == 'xuxu')
b('set', 10); assert(b('get') == 14)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -178,7 +179,7 @@ test("[test-suite] closure: testing closure x break x return x errors", function
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -204,7 +205,7 @@ test("[test-suite] closure: testing multi-level closure", function (t) {
w = 1.345
assert(y(20)(30) == 60+w)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -213,7 +214,7 @@ test("[test-suite] closure: testing multi-level closure", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -236,7 +237,7 @@ test("[test-suite] closure: testing closures x repeat-until", function (t) {
until i > 10 or a[i]() ~= x
assert(i == 11 and a[1]() == 1 and a[3]() == 3 and i == 4)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -245,7 +246,7 @@ test("[test-suite] closure: testing closures x repeat-until", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -289,7 +290,7 @@ test("[test-suite] closure: testing closures created in 'then' and 'else' parts
assert(a[i](i * 10) == i % 3 and a[i]() == i * 10)
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -298,7 +299,7 @@ test("[test-suite] closure: testing closures created in 'then' and 'else' parts
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -321,7 +322,7 @@ test("[test-suite] closure: test for correctly closing upvalues in tail calls of
end
t()
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -330,7 +331,7 @@ test("[test-suite] closure: test for correctly closing upvalues in tail calls of
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
diff --git a/tests/test-suite/code.js b/tests/test-suite/code.js
index 26ca021..57c97cb 100644
--- a/tests/test-suite/code.js
+++ b/tests/test-suite/code.js
@@ -5,10 +5,10 @@ const test = require('tape');
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
const lualib = require('../../src/lualib.js');
+const {to_luastring} = require("../../src/fengaricore.js");
const ltests = require('./ltests.js');
-
test("[test-suite] code: testing reuse in constant table", function (t) {
let luaCode = `
local function checkKlist (func, list)
@@ -31,7 +31,7 @@ test("[test-suite] code: testing reuse in constant table", function (t) {
checkKlist(foo, {3, 0, 0.0, 3.78/4, -3.78/4, -3.79/4, 3.0})
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -42,7 +42,7 @@ test("[test-suite] code: testing reuse in constant table", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -83,7 +83,7 @@ test("[test-suite] code: some basic instructions", function (t) {
(function () end){f()}
end, 'CLOSURE', 'NEWTABLE', 'GETTABUP', 'CALL', 'SETLIST', 'CALL', 'RETURN')
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -94,7 +94,7 @@ test("[test-suite] code: some basic instructions", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -126,7 +126,7 @@ test("[test-suite] code: sequence of LOADNILs", function (t) {
assert(a == nil and b == nil and c == nil and d == nil)
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -137,7 +137,7 @@ test("[test-suite] code: sequence of LOADNILs", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -153,7 +153,7 @@ test("[test-suite] code: single return", function (t) {
let luaCode = `
check (function (a,b,c) return a end, 'RETURN')
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -164,7 +164,7 @@ test("[test-suite] code: single return", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -187,7 +187,7 @@ test("[test-suite] code: infinite loops", function (t) {
check(function () repeat local x = 1 until true end,
'LOADK', 'RETURN')
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -198,7 +198,7 @@ test("[test-suite] code: infinite loops", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -215,7 +215,7 @@ test("[test-suite] code: concat optimization", function (t) {
check(function (a,b,c,d) return a..b..c..d end,
'MOVE', 'MOVE', 'MOVE', 'MOVE', 'CONCAT', 'RETURN')
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -226,7 +226,7 @@ test("[test-suite] code: concat optimization", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -245,7 +245,7 @@ test("[test-suite] code: not", function (t) {
check(function () return not not true end, 'LOADBOOL', 'RETURN')
check(function () return not not 1 end, 'LOADBOOL', 'RETURN')
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -256,7 +256,7 @@ test("[test-suite] code: not", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -280,7 +280,7 @@ test("[test-suite] code: direct access to locals", function (t) {
'DIV', 'ADD', 'GETTABLE', 'SUB', 'GETTABLE', 'POW',
'UNM', 'SETTABLE', 'SETTABLE', 'RETURN')
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -291,7 +291,7 @@ test("[test-suite] code: direct access to locals", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -327,7 +327,7 @@ test("[test-suite] code: direct access to constants", function (t) {
end,
'LOADNIL', 'SETTABLE', 'RETURN')
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -338,7 +338,7 @@ test("[test-suite] code: direct access to constants", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -373,7 +373,7 @@ test("[test-suite] code: constant folding", function (t) {
checkK(function () return ~~-100024.0 end, -100024)
checkK(function () return ((100 << 6) << -4) >> 2 end, 100)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -384,7 +384,7 @@ test("[test-suite] code: constant folding", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -403,7 +403,7 @@ test("[test-suite] code: no folding", function (t) {
check(function () return 0%0 end, 'MOD', 'RETURN')
check(function () return -4//0 end, 'IDIV', 'RETURN')
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -414,7 +414,7 @@ test("[test-suite] code: no folding", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -437,7 +437,7 @@ test("[test-suite] code: bug in constant folding for 5.1", function (t) {
b[a], a = c, b
a, b = c, a
a = a
- end,
+ end,
'LOADNIL',
'MOVE', 'MOVE', 'SETTABLE',
'MOVE', 'MOVE', 'MOVE', 'SETTABLE',
@@ -445,7 +445,7 @@ test("[test-suite] code: bug in constant folding for 5.1", function (t) {
-- no code for a = a
'RETURN')
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -456,7 +456,7 @@ test("[test-suite] code: bug in constant folding for 5.1", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -482,7 +482,7 @@ test("[test-suite] code: x == nil , x ~= nil", function (t) {
checkequal(function (l) local a; return 0 <= a and a <= l end,
function (l) local a; return not (not(a >= 0) or not(a <= l)) end)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -493,7 +493,7 @@ test("[test-suite] code: x == nil , x ~= nil", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -515,7 +515,7 @@ test("[test-suite] code: if-goto optimizations", function (t) {
else goto l3
end
end
- ::l1:: ::l2:: ::l3:: ::l4::
+ ::l1:: ::l2:: ::l3:: ::l4::
end, 'EQ', 'JMP', 'EQ', 'JMP', 'EQ', 'JMP', 'EQ', 'JMP', 'JMP', 'RETURN')
checkequal(
@@ -529,7 +529,7 @@ test("[test-suite] code: if-goto optimizations", function (t) {
function (a) while true do if not(a < 10) then break end; a = a + 1; end end
)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -540,7 +540,7 @@ test("[test-suite] code: if-goto optimizations", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
diff --git a/tests/test-suite/constructs.js b/tests/test-suite/constructs.js
index 89bcce7..93bbf1a 100644
--- a/tests/test-suite/constructs.js
+++ b/tests/test-suite/constructs.js
@@ -5,7 +5,7 @@ const test = require('tape');
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
const lualib = require('../../src/lualib.js');
-
+const {to_luastring} = require("../../src/fengaricore.js");
const checkload = `
local function checkload (s, msg)
@@ -28,7 +28,7 @@ test('[test-suite] constructs: testing semicolons', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkload + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(checkload + luaCode));
}, "Lua program loaded without error");
@@ -54,7 +54,7 @@ test('[test-suite] constructs: invalid operations should not raise errors when n
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkload + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(checkload + luaCode));
}, "Lua program loaded without error");
@@ -119,7 +119,7 @@ test('[test-suite] constructs: testing priorities', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkload + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(checkload + luaCode));
}, "Lua program loaded without error");
@@ -305,7 +305,7 @@ test('[test-suite] constructs: silly loops', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkload + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(checkload + luaCode));
}, "Lua program loaded without error");
@@ -392,7 +392,7 @@ test.skip('[test-suite] constructs: huge loops, upvalue', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkload + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(checkload + luaCode));
}, "Lua program loaded without error");
@@ -428,7 +428,7 @@ test("[test-suite] constructs: testing some syntax errors (chosen through 'gcov'
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkload + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(checkload + luaCode));
}, "Lua program loaded without error");
diff --git a/tests/test-suite/coroutine.js b/tests/test-suite/coroutine.js
index b85f0de..969c65e 100644
--- a/tests/test-suite/coroutine.js
+++ b/tests/test-suite/coroutine.js
@@ -5,6 +5,7 @@ const test = require('tape');
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
const lualib = require('../../src/lualib.js');
+const {to_luastring} = require("../../src/fengaricore.js");
const ltests = require('./ltests.js');
@@ -64,7 +65,7 @@ test("[test-suite] coroutine: is main thread", function (t) {
assert(not coroutine.isyieldable())
assert(not pcall(coroutine.yield))
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -73,7 +74,7 @@ test("[test-suite] coroutine: is main thread", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -91,7 +92,7 @@ test("[test-suite] coroutine: trivial errors", function (t) {
assert(not pcall(coroutine.resume, 0))
assert(not pcall(coroutine.status, 0))
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -100,7 +101,7 @@ test("[test-suite] coroutine: trivial errors", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -158,7 +159,7 @@ test("[test-suite] coroutine: tests for multiple yield/resume arguments", functi
s, a = coroutine.resume(f, "xuxu")
assert(not s and string.find(a, "dead") and coroutine.status(f) == "dead")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -167,7 +168,7 @@ test("[test-suite] coroutine: tests for multiple yield/resume arguments", functi
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -192,7 +193,7 @@ test("[test-suite] coroutine: yields in tail calls", function (t) {
for i=1,10 do _G.x = i; assert(f(i) == i) end
_G.x = 'xuxu'; assert(f('xuxu') == 'a')
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -201,7 +202,7 @@ test("[test-suite] coroutine: yields in tail calls", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -228,7 +229,7 @@ test("[test-suite] coroutine: recursive", function (t) {
s = s*i
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -237,7 +238,7 @@ test("[test-suite] coroutine: recursive", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -281,7 +282,7 @@ test("[test-suite] coroutine: sieve", function (t) {
assert(#a == 25 and a[#a] == 97)
x, a = nil
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -290,7 +291,7 @@ test("[test-suite] coroutine: sieve", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -333,7 +334,7 @@ test("[test-suite] coroutine: yielding across JS boundaries", function (t) {
r, msg = co(100)
assert(not r and msg == 240)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -342,7 +343,7 @@ test("[test-suite] coroutine: yielding across JS boundaries", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -371,7 +372,7 @@ test("[test-suite] coroutine: unyieldable JS call", function (t) {
assert(co() == "aa")
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -380,7 +381,7 @@ test("[test-suite] coroutine: unyieldable JS call", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -416,7 +417,7 @@ test("[test-suite] coroutine: errors in coroutines", function (t) {
a,b = coroutine.resume(x)
assert(not a and string.find(b, "dead") and coroutine.status(x) == "dead")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -425,7 +426,7 @@ test("[test-suite] coroutine: errors in coroutines", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -456,7 +457,7 @@ test("[test-suite] coroutine: co-routines x for loop", function (t) {
end
assert(a == 5^4)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -465,7 +466,7 @@ test("[test-suite] coroutine: co-routines x for loop", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -499,7 +500,7 @@ test("[test-suite] coroutine: old bug: attempt to resume itself", function (t) {
assert(coroutine.resume(co, co) == false)
assert(coroutine.resume(co, co) == false)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -508,7 +509,7 @@ test("[test-suite] coroutine: old bug: attempt to resume itself", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -534,7 +535,7 @@ test("[test-suite] coroutine: old bug: other old bug when attempting to resume i
assert(not st and string.find(res, "non%-suspended"))
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -543,7 +544,7 @@ test("[test-suite] coroutine: old bug: other old bug when attempting to resume i
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -570,7 +571,7 @@ test("[test-suite] coroutine: attempt to resume 'normal' coroutine", function (t
assert(a and b == 3)
assert(coroutine.status(co1) == 'dead')
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -579,7 +580,7 @@ test("[test-suite] coroutine: attempt to resume 'normal' coroutine", function (t
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -598,7 +599,7 @@ test("[test-suite] coroutine: infinite recursion of coroutines", function (t) {
assert(not pcall(a, a))
a = nil
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -607,7 +608,7 @@ test("[test-suite] coroutine: infinite recursion of coroutines", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -634,7 +635,7 @@ test("[test-suite] coroutine: access to locals of erroneous coroutines", functio
assert(_G.f() == 11)
assert(_G.f() == 12)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -643,7 +644,7 @@ test("[test-suite] coroutine: access to locals of erroneous coroutines", functio
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -665,7 +666,7 @@ test("[test-suite] coroutine: leaving a pending coroutine open", function (t) {
_X()
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -674,7 +675,7 @@ test("[test-suite] coroutine: leaving a pending coroutine open", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -714,7 +715,7 @@ test("[test-suite] coroutine: stack overflow", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -774,7 +775,7 @@ test("[test-suite] coroutine: testing yields inside metamethods", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -812,7 +813,7 @@ test("[test-suite] coroutine: tests for comparsion operators", function (t) {
until res ~= 10
return res
end
-
+
local function test ()
local a1 = setmetatable({x=1}, mt1)
local a2 = setmetatable({x=2}, mt2)
@@ -824,7 +825,7 @@ test("[test-suite] coroutine: tests for comparsion operators", function (t) {
assert(2 >= a2)
return true
end
-
+
run(test)
end
@@ -838,7 +839,7 @@ test("[test-suite] coroutine: tests for comparsion operators", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -870,7 +871,7 @@ test("[test-suite] coroutine: getuptable & setuptable", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -905,7 +906,7 @@ test("[test-suite] coroutine: testing yields inside 'for' iterators", function (
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -950,7 +951,7 @@ test("[test-suite] coroutine: testing yields inside hooks", function (t) {
assert(B // A == 7) -- fact(7) // fact(6)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -961,7 +962,7 @@ test("[test-suite] coroutine: testing yields inside hooks", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(jsprefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(jsprefix + luaCode));
}, "Lua program loaded without error");
@@ -993,7 +994,7 @@ test("[test-suite] coroutine: testing yields inside line hook", function (t) {
_G.X = nil; co(); assert(_G.X == line + 3 and _G.XX == 20)
assert(co() == 10)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1004,7 +1005,7 @@ test("[test-suite] coroutine: testing yields inside line hook", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(jsprefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(jsprefix + luaCode));
}, "Lua program loaded without error");
@@ -1034,7 +1035,7 @@ test("[test-suite] coroutine: testing yields in count hook", function (t) {
repeat c = c + 1; local a = co() until a == 10
assert(_G.XX == 20 and c >= 5)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1045,7 +1046,7 @@ test("[test-suite] coroutine: testing yields in count hook", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(jsprefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(jsprefix + luaCode));
}, "Lua program loaded without error");
@@ -1084,7 +1085,7 @@ test("[test-suite] coroutine: testing yields inside line hook", function (t) {
assert(_G.XX == 20 and c >= 5)
_G.X = nil; _G.XX = nil
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1095,7 +1096,7 @@ test("[test-suite] coroutine: testing yields inside line hook", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(jsprefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(jsprefix + luaCode));
}, "Lua program loaded without error");
@@ -1136,7 +1137,7 @@ test("[test-suite] coroutine: testing debug library on a coroutine suspended ins
assert(not coroutine.resume(c))
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1147,7 +1148,7 @@ test("[test-suite] coroutine: testing debug library on a coroutine suspended ins
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -1172,7 +1173,7 @@ test("[test-suite] coroutine: testing debug library on last function in a suspen
assert(b == 10)
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1183,7 +1184,7 @@ test("[test-suite] coroutine: testing debug library on last function in a suspen
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -1218,7 +1219,7 @@ test("[test-suite] coroutine: reusing a thread", function (t) {
assert(X == 'a a a' and Y == 'OK')
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1229,7 +1230,7 @@ test("[test-suite] coroutine: reusing a thread", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -1267,7 +1268,7 @@ test("[test-suite] coroutine: resuming running coroutine", function (t) {
assert(a == coroutine.running() and string.find(b, "non%-suspended") and
c == "ERRRUN" and d == 4)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1278,7 +1279,7 @@ test("[test-suite] coroutine: resuming running coroutine", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -1322,7 +1323,7 @@ test("[test-suite] coroutine: using a main thread as a coroutine", function (t)
T.closestate(state)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1333,7 +1334,7 @@ test("[test-suite] coroutine: using a main thread as a coroutine", function (t)
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -1386,7 +1387,7 @@ test("[test-suite] coroutine: tests for coroutine API", function (t) {
a[9] == "YIELD" and a[10] == 4)
assert(not pcall(co)) -- coroutine is dead now
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1397,7 +1398,7 @@ test("[test-suite] coroutine: tests for coroutine API", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -1419,7 +1420,7 @@ test("[test-suite] coroutine: tests for coroutine API", function (t) {
assert(co(23,16) == 5)
assert(co(23,16) == 10)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1430,7 +1431,7 @@ test("[test-suite] coroutine: tests for coroutine API", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -1476,7 +1477,7 @@ test("[test-suite] coroutine: testing coroutines with C bodies", function (t) {
assert(a == 'YIELD' and b == 'a' and c == 102 and d == 'OK')
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1487,7 +1488,7 @@ test("[test-suite] coroutine: testing coroutines with C bodies", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -1531,7 +1532,7 @@ test("[test-suite] coroutine: testing chain of suspendable C calls", function (t
-- three '34's (one from each pending C call)
assert(#a == 3 and a[1] == a[2] and a[2] == a[3] and a[3] == 34)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1542,7 +1543,7 @@ test("[test-suite] coroutine: testing chain of suspendable C calls", function (t
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -1562,11 +1563,11 @@ test("[test-suite] coroutine: testing yields with continuations", function (t) {
cannot be here!
]],
[[ # 1st continuation
- yieldk 0 3
+ yieldk 0 3
cannot be here!
]],
[[ # 2nd continuation
- yieldk 0 4
+ yieldk 0 4
cannot be here!
]],
[[ # 3th continuation
@@ -1608,7 +1609,7 @@ test("[test-suite] coroutine: testing yields with continuations", function (t) {
assert(not pcall(co)) -- coroutine should be dead
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1619,7 +1620,7 @@ test("[test-suite] coroutine: testing yields with continuations", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -1641,7 +1642,7 @@ test("[test-suite] coroutine: bug in nCcalls", function (t) {
local a = {co()}
assert(a[10] == "hi")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1652,7 +1653,7 @@ test("[test-suite] coroutine: bug in nCcalls", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
diff --git a/tests/test-suite/db.js b/tests/test-suite/db.js
index ff13ecb..9209ab9 100644
--- a/tests/test-suite/db.js
+++ b/tests/test-suite/db.js
@@ -5,7 +5,7 @@ const test = require('tape');
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
const lualib = require('../../src/lualib.js');
-
+const {to_luastring} = require("../../src/fengaricore.js");
const prefix = `
local function dostring(s) return assert(load(s))() end
@@ -51,7 +51,7 @@ test("[test-suite] db: getinfo, ...line...", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -99,7 +99,7 @@ test("[test-suite] db: test file and string names truncation", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -158,7 +158,7 @@ test("[test-suite] db: local", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -236,7 +236,7 @@ test("[test-suite] db: line hook", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -263,7 +263,7 @@ test("[test-suite] db: invalid levels in [gs]etlocal", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -299,7 +299,7 @@ test("[test-suite] db: parameter names", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -348,7 +348,7 @@ test("[test-suite] db: vararg", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -375,7 +375,7 @@ test("[test-suite] db: access to vararg in non-vararg function", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -483,7 +483,7 @@ test("[test-suite] db: test hook presence in debug info", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -529,7 +529,7 @@ test("[test-suite] db: tests for manipulating non-registered locals (C and Lua t
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -590,7 +590,7 @@ test("[test-suite] db: testing access to function arguments", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -649,7 +649,7 @@ test("[test-suite] db: testing access to local variables in return hook (bug in
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -701,7 +701,7 @@ test("[test-suite] db: testing upvalue access", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -743,7 +743,7 @@ test("[test-suite] db: testing count hooks", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -822,7 +822,7 @@ test("[test-suite] db: tests for tail calls", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -864,7 +864,7 @@ test("[test-suite] db: testing local function information", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -901,7 +901,7 @@ test("[test-suite] db: testing traceback", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -938,7 +938,7 @@ test("[test-suite] db: testing nparams, nups e isvararg", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -1028,8 +1028,8 @@ test("[test-suite] db: testing debugging of coroutines", function (t) {
lualib.luaL_openlibs(L);
- let b = lua.to_luastring(luaCode);
- if (lauxlib.luaL_loadbuffer(L, b, b.length, lua.to_luastring("@db.lua")) !== lua.LUA_OK)
+ let b = to_luastring(luaCode);
+ if (lauxlib.luaL_loadbuffer(L, b, b.length, to_luastring("@db.lua")) !== lua.LUA_OK)
throw Error(lua.lua_tojsstring(L, -1));
}, "Lua program loaded without error");
@@ -1069,7 +1069,7 @@ test("[test-suite] db: check get/setlocal in coroutines", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -1116,7 +1116,7 @@ test("[test-suite] db: check traceback of suspended (or dead with error) corouti
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -1159,7 +1159,7 @@ test("[test-suite] db: check test acessing line numbers of a coroutine from a re
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -1211,7 +1211,7 @@ test("[test-suite] db: test tagmethod information", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -1243,7 +1243,7 @@ test("[test-suite] db: testing for-iterator name", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -1302,8 +1302,8 @@ test("[test-suite] db: testing traceback sizes", function (t) {
lualib.luaL_openlibs(L);
- let b = lua.to_luastring(luaCode);
- if (lauxlib.luaL_loadbuffer(L, b, b.length, lua.to_luastring("@db.lua")) !== lua.LUA_OK)
+ let b = to_luastring(luaCode);
+ if (lauxlib.luaL_loadbuffer(L, b, b.length, to_luastring("@db.lua")) !== lua.LUA_OK)
throw Error(lua.lua_tojsstring(L, -1));
}, "Lua program loaded without error");
@@ -1371,7 +1371,7 @@ test("[test-suite] db: testing debug functions on chunk without debug info", fun
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -1427,7 +1427,7 @@ test("[test-suite] db: tests for 'source' in binary dumps", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
diff --git a/tests/test-suite/errors.js b/tests/test-suite/errors.js
index a6bc351..0b05e9d 100644
--- a/tests/test-suite/errors.js
+++ b/tests/test-suite/errors.js
@@ -5,7 +5,7 @@ const test = require('tape');
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
const lualib = require('../../src/lualib.js');
-
+const {to_luastring} = require("../../src/fengaricore.js");
const prefix = `
-- avoid problems with 'strict' module (which may generate other error messages)
@@ -48,7 +48,7 @@ test("[test-suite] errors: test error message with no extra info", function (t)
let luaCode = `
assert(doit("error('hi', 0)") == 'hi')
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -57,7 +57,7 @@ test("[test-suite] errors: test error message with no extra info", function (t)
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -74,7 +74,7 @@ test("[test-suite] errors: test error message with no info", function (t) {
let luaCode = `
assert(doit("error()") == nil)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -83,7 +83,7 @@ test("[test-suite] errors: test error message with no info", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -115,7 +115,7 @@ test("[test-suite] errors: test common errors/errors that crashed in the past",
]], "'}' expected (to close '{' at line 1)", "<eof>", 3)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -124,7 +124,7 @@ test("[test-suite] errors: test common errors/errors that crashed in the past",
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -161,7 +161,7 @@ test("[test-suite] errors: tests for better error messages", function (t) {
checkmessage("local a,b,c; (function () a = b+1 end)()", "upvalue 'b'")
assert(not doit"local aaa={bbb={ddd=next}}; aaa.bbb:ddd(nil)")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -170,7 +170,7 @@ test("[test-suite] errors: tests for better error messages", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -195,7 +195,7 @@ test("[test-suite] errors: upvalues being indexed do not go to the stack", funct
checkmessage("aaa='2'; b=nil;x=aaa*b", "global 'b'")
checkmessage("aaa={}; x=-aaa", "global 'aaa'")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -204,7 +204,7 @@ test("[test-suite] errors: upvalues being indexed do not go to the stack", funct
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -232,7 +232,7 @@ test("[test-suite] errors: short circuit", function (t) {
checkmessage("print('10' < 10)", "string with number")
checkmessage("print(10 < '23')", "number with string")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -241,7 +241,7 @@ test("[test-suite] errors: short circuit", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -274,7 +274,7 @@ test("[test-suite] errors: float->integer conversions", function (t) {
checkmessage("a = 24 // 0", "divide by zero")
checkmessage("a = 1 % 0", "'n%0'")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -283,7 +283,7 @@ test("[test-suite] errors: float->integer conversions", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -306,7 +306,7 @@ test("[test-suite] errors: passing light userdata instead of full userdata", fun
]], "light userdata")
_G.D = nil
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -315,7 +315,7 @@ test("[test-suite] errors: passing light userdata instead of full userdata", fun
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -343,7 +343,7 @@ test("[test-suite] errors: named objects (field '__name')", function (t) {
_G.XX = nil
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -352,7 +352,7 @@ test("[test-suite] errors: named objects (field '__name')", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -370,7 +370,7 @@ test("[test-suite] errors: global functions", function (t) {
checkmessage("(io.write or print){}", "io.write")
checkmessage("(collectgarbage or print){}", "collectgarbage")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -379,7 +379,7 @@ test("[test-suite] errors: global functions", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -408,7 +408,7 @@ test("[test-suite] errors: errors in functions without debug info", function (t)
checkerr("^%?:%-1:.*table value", f)
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -417,7 +417,7 @@ test("[test-suite] errors: errors in functions without debug info", function (t)
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -443,7 +443,7 @@ test("[test-suite] errors: tests for field accesses after RK limit", function (t
checkmessage(s.."; local t = {}; a = t.bbb + 1", "field 'bbb'")
checkmessage(s.."; local t = {}; t:bbb()", "method 'bbb'")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -452,7 +452,7 @@ test("[test-suite] errors: tests for field accesses after RK limit", function (t
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -478,7 +478,7 @@ test("[test-suite] errors: global", function (t) {
{d = x and aaa[x or y]}}
]], "global 'aaa'")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -487,7 +487,7 @@ test("[test-suite] errors: global", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -507,7 +507,7 @@ test("[test-suite] errors: field", function (t) {
if math.sin(1) == 0 then return 3 end -- return
x.a()]], "field 'a'")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -516,7 +516,7 @@ test("[test-suite] errors: field", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -540,7 +540,7 @@ test("[test-suite] errors: global insert", function (t) {
insert(prefix, a)
end]], "global 'insert'")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -549,7 +549,7 @@ test("[test-suite] errors: global insert", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -568,7 +568,7 @@ test("[test-suite] errors: sin", function (t) {
return math.sin("a")
]], "'sin'")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -577,7 +577,7 @@ test("[test-suite] errors: sin", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -596,7 +596,7 @@ test("[test-suite] errors: concatenate", function (t) {
checkmessage([[x = "a" .. false]], "concatenate")
checkmessage([[x = {} .. 2]], "concatenate")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -605,7 +605,7 @@ test("[test-suite] errors: concatenate", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -628,7 +628,7 @@ test("[test-suite] errors: unknown global", function (t) {
main()
]], "global 'NoSuchName'")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -637,7 +637,7 @@ test("[test-suite] errors: unknown global", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -660,7 +660,7 @@ test("[test-suite] errors: __index", function (t) {
checkmessage("table.sort({1,2,3}, table.sort)", "'table.sort'")
checkmessage("string.gsub('s', 's', setmetatable)", "'setmetatable'")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -669,7 +669,7 @@ test("[test-suite] errors: __index", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -696,7 +696,7 @@ test("[test-suite] errors: tests for errors in coroutines", function (t) {
f = coroutine.wrap(function () table.sort({1,2,3}, coroutine.yield) end)
checkerr("yield across", f)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -705,7 +705,7 @@ test("[test-suite] errors: tests for errors in coroutines", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -735,7 +735,7 @@ test("[test-suite] errors: testing size of 'source' info", function (t) {
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -744,7 +744,7 @@ test("[test-suite] errors: testing size of 'source' info", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -812,7 +812,7 @@ test("[test-suite] errors: testing line error", function (t) {
X=1;lineerror((p), 2)
X=2;lineerror((p), 1)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -821,7 +821,7 @@ test("[test-suite] errors: testing line error", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -847,7 +847,7 @@ test("[test-suite] errors: several tests that exhaust the Lua stack", function (
assert(checkstackmessage(doit('y()')))
assert(checkstackmessage(doit('y()')))
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -856,7 +856,7 @@ test("[test-suite] errors: several tests that exhaust the Lua stack", function (
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -890,7 +890,7 @@ test("[test-suite] errors: error lines in stack overflow", function (t) {
end
assert(i > 15)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -899,7 +899,7 @@ test("[test-suite] errors: error lines in stack overflow", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -927,7 +927,7 @@ test("[test-suite] errors: error in error handling", function (t) {
end
f(3)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -936,7 +936,7 @@ test("[test-suite] errors: error in error handling", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -966,7 +966,7 @@ test("[test-suite] errors: too many results", function (t) {
end
checkerr("too many results", f)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -975,7 +975,7 @@ test("[test-suite] errors: too many results", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1006,7 +1006,7 @@ test("[test-suite] errors: non string messages", function (t) {
-- 'assert' with extra arguments
res, msg = pcall(assert, false, "X", t)
assert(not res and msg == "X")
-
+
-- 'assert' with no message
res, msg = pcall(function () assert(false) end)
local line = string.match(msg, "%w+%.lua:(%d+): assertion failed!$")
@@ -1024,7 +1024,7 @@ test("[test-suite] errors: non string messages", function (t) {
assert(not res and string.find(msg, "value expected"))
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1033,7 +1033,7 @@ test("[test-suite] errors: non string messages", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadbuffer(L, lua.to_luastring(prefix + luaCode), null, lua.to_luastring("@errors.lua"));
+ lauxlib.luaL_loadbuffer(L, to_luastring(prefix + luaCode), null, to_luastring("@errors.lua"));
}, "Lua program loaded without error");
@@ -1053,7 +1053,7 @@ test("[test-suite] errors: xpcall with arguments", function (t) {
a, b, c = xpcall(string.find, function (x) return {} end, true, "al")
assert(not a and type(b) == "table" and c == nil)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1062,7 +1062,7 @@ test("[test-suite] errors: xpcall with arguments", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1084,7 +1084,7 @@ test("[test-suite] errors: testing tokens in error messages", function (t) {
checksyntax("while << do end", "", "<<", 1)
checksyntax("for >> do end", "", ">>", 1)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1093,7 +1093,7 @@ test("[test-suite] errors: testing tokens in error messages", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1110,7 +1110,7 @@ test("[test-suite] errors: test invalid non-printable char in a chunk", function
let luaCode = `
checksyntax("a\\1a = 1", "", "<\\\\1>", 1)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1119,7 +1119,7 @@ test("[test-suite] errors: test invalid non-printable char in a chunk", function
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1139,7 +1139,7 @@ test("[test-suite] errors: test 255 as first char in a chunk", function (t) {
doit('I = load("a=9+"); a=3')
assert(a==3 and I == nil)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1148,7 +1148,7 @@ test("[test-suite] errors: test 255 as first char in a chunk", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1170,7 +1170,7 @@ test("[test-suite] errors: lots of errors", function (t) {
doit('a = 4+nil')
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1179,7 +1179,7 @@ test("[test-suite] errors: lots of errors", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1217,7 +1217,7 @@ test("[test-suite] errors: testing syntax limits", function (t) {
checkmessage("a = f(x" .. string.rep(",x", 260) .. ")", "too many registers")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1226,7 +1226,7 @@ test("[test-suite] errors: testing syntax limits", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1263,7 +1263,7 @@ test("[test-suite] errors: upvalues limit", function (t) {
assert(c > 255 and string.find(b, "too many upvalues") and
string.find(b, "line 5"))
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1272,7 +1272,7 @@ test("[test-suite] errors: upvalues limit", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1295,7 +1295,7 @@ test("[test-suite] errors: local variables limit", function (t) {
local a,b = load(s)
assert(string.find(b, "line 2") and string.find(b, "too many local variables"))
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1304,7 +1304,7 @@ test("[test-suite] errors: local variables limit", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
diff --git a/tests/test-suite/events.js b/tests/test-suite/events.js
index 9a15e93..143bdf5 100644
--- a/tests/test-suite/events.js
+++ b/tests/test-suite/events.js
@@ -5,10 +5,10 @@ const test = require('tape');
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
const lualib = require('../../src/lualib.js');
+const {to_luastring} = require("../../src/fengaricore.js");
const ltests = require('./ltests.js');
-
test("[test-suite] events: testing metatable", function (t) {
let luaCode = `
X = 20; B = 30
@@ -182,7 +182,7 @@ test("[test-suite] events: testing metatable", function (t) {
assert(1.5 >> a == 1.5)
assert(cap[0] == "shr" and cap[1] == 1.5 and cap[2] == a)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -191,7 +191,7 @@ test("[test-suite] events: testing metatable", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -216,7 +216,7 @@ test("[test-suite] events: test for rawlen", function (t) {
-- rawlen for long strings
assert(rawlen(string.rep('a', 1000)) == 1000)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -225,7 +225,7 @@ test("[test-suite] events: test for rawlen", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -277,7 +277,7 @@ test("[test-suite] events: test comparison", function (t) {
test() -- retest comparisons, now using both 'lt' and 'le'
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -286,7 +286,7 @@ test("[test-suite] events: test comparison", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -360,7 +360,7 @@ test("[test-suite] events: test 'partial order'", function (t) {
t[Set{1,3,5}] = 1
assert(t[Set{1,3,5}] == nil)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -369,7 +369,7 @@ test("[test-suite] events: test 'partial order'", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -403,7 +403,7 @@ test("[test-suite] events: __eq between userdata", function (t) {
assert(u2 == u1 and u2 == u3 and u3 == u2)
assert(u2 ~= {}) -- different types cannot be equal
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -414,7 +414,7 @@ test("[test-suite] events: __eq between userdata", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -455,7 +455,7 @@ test("[test-suite] events: concat", function (t) {
x = 0 .."a".."b"..c..d.."e".."f".."g"
assert(x.val == "0abcdefg")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -466,7 +466,7 @@ test("[test-suite] events: concat", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -490,7 +490,7 @@ test("[test-suite] events: concat metamethod x numbers (bug in 5.1.1)", function
assert(c..5 == c and 5 .. c == c)
assert(4 .. c .. 5 == c and 4 .. 5 .. 6 .. 7 .. c == c)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -501,7 +501,7 @@ test("[test-suite] events: concat metamethod x numbers (bug in 5.1.1)", function
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -529,7 +529,7 @@ test("[test-suite] events: test comparison compatibilities", function (t) {
setmetatable(d, t2)
assert(c == d and c < d and not(d <= c))
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -540,7 +540,7 @@ test("[test-suite] events: test comparison compatibilities", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -564,16 +564,16 @@ test("[test-suite] events: test for several levels of callstest for several leve
end
end
}
-
+
local a = setmetatable({}, tt)
local b = setmetatable({f=a}, tt)
local c = setmetatable({f=b}, tt)
-
+
i = 0
x = c(3,4,5)
assert(i == 3 and x[1] == 3 and x[3] == 5)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -584,7 +584,7 @@ test("[test-suite] events: test for several levels of callstest for several leve
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -606,7 +606,7 @@ test("[test-suite] events: __index on _ENV", function (t) {
rawset(a, "x", 1, 2, 3)
assert(a.x == 1 and rawget(a, "x", 3) == 1)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -617,7 +617,7 @@ test("[test-suite] events: __index on _ENV", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -661,7 +661,7 @@ test("[test-suite] events: testing metatables for basic types", function (t) {
debug.setmetatable(nil, {})
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -672,7 +672,7 @@ test("[test-suite] events: testing metatables for basic types", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -691,7 +691,7 @@ test("[test-suite] events: loops in delegation", function (t) {
assert(not pcall(function (a,b) return a[b] end, a, 10))
assert(not pcall(function (a,b,c) a[b] = c end, a, 10, true))
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -702,7 +702,7 @@ test("[test-suite] events: loops in delegation", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -729,7 +729,7 @@ test("[test-suite] events: bug in 5.1", function (t) {
child.foo = 10 --> CRASH (on some machines)
assert(T == parent and K == "foo" and V == 10)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -740,7 +740,7 @@ test("[test-suite] events: bug in 5.1", function (t) {
ltests.luaopen_tests(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
diff --git a/tests/test-suite/goto.js b/tests/test-suite/goto.js
index 5acf633..dc52c73 100644
--- a/tests/test-suite/goto.js
+++ b/tests/test-suite/goto.js
@@ -5,7 +5,7 @@ const test = require('tape');
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
const lualib = require('../../src/lualib.js');
-
+const {to_luastring} = require("../../src/fengaricore.js");
test("[test-suite] goto: error messages", function (t) {
let luaCode = `
@@ -45,7 +45,7 @@ test("[test-suite] goto: error messages", function (t) {
until xuxu < x
]], "local 'xuxu'")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -54,7 +54,7 @@ test("[test-suite] goto: error messages", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -124,7 +124,7 @@ test("[test-suite] goto", function (t) {
::l1:: ; ::l2:: ;;
else end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -133,7 +133,7 @@ test("[test-suite] goto", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -164,7 +164,7 @@ test("[test-suite] goto: to repeat a label in a different function is OK", funct
::l6:: foo()
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -173,7 +173,7 @@ test("[test-suite] goto: to repeat a label in a different function is OK", funct
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -203,7 +203,7 @@ test("[test-suite] goto: bug in 5.2 -> 5.3.2", function (t) {
assert(x == 2 and y == true)
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -212,7 +212,7 @@ test("[test-suite] goto: bug in 5.2 -> 5.3.2", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -288,7 +288,7 @@ test("[test-suite] goto: testing closing of upvalues", function (t) {
end
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -297,7 +297,7 @@ test("[test-suite] goto: testing closing of upvalues", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -342,7 +342,7 @@ test("[test-suite] goto: testing if x goto optimizations", function (t) {
assert(testG(4) == 5)
assert(testG(5) == 10)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -351,7 +351,7 @@ test("[test-suite] goto: testing if x goto optimizations", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
diff --git a/tests/test-suite/literals.js b/tests/test-suite/literals.js
index 0078cf8..6e3205e 100644
--- a/tests/test-suite/literals.js
+++ b/tests/test-suite/literals.js
@@ -5,7 +5,7 @@ const test = require('tape');
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
const lualib = require('../../src/lualib.js');
-
+const {to_luastring} = require("../../src/fengaricore.js");
const dostring = `
local function dostring (x) return assert(load(x), "")() end
@@ -16,7 +16,7 @@ test("[test-suite] literals: dostring", function (t) {
dostring("x \\v\\f = \\t\\r 'a\\0a' \\v\\f\\f")
assert(x == 'a\\0a' and string.len(x) == 3)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -25,7 +25,7 @@ test("[test-suite] literals: dostring", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(dostring + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode));
}, "Lua program loaded without error");
@@ -46,7 +46,7 @@ test("[test-suite] literals: escape sequences", function (t) {
"'\\]])
assert(string.find("\\b\\f\\n\\r\\t\\v", "^%c%c%c%c%c%c$"))
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -55,7 +55,7 @@ test("[test-suite] literals: escape sequences", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -78,7 +78,7 @@ test("[test-suite] literals: assume ASCII just for tests", function (t) {
assert(010 .. 020 .. -030 == "1020-30")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -87,7 +87,7 @@ test("[test-suite] literals: assume ASCII just for tests", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -125,7 +125,7 @@ assert("abc\\z
ghi\\z
" == 'abcdefghi')
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -134,7 +134,7 @@ assert("abc\\z
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -163,7 +163,7 @@ test("[test-suite] literals: UTF-8 sequences", function (t) {
-- limits for 4-byte sequences
assert("\\u{10000}\\u{10FFFF}" == "\\xF0\\x90\\x80\\x80\\z\\xF4\\x8F\\xBF\\xBF")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -172,7 +172,7 @@ test("[test-suite] literals: UTF-8 sequences", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -229,7 +229,7 @@ test("[test-suite] literals: Error in escape sequences", function (t) {
lexerror("'alo \\\\z", "<eof>")
lexerror([['alo \\98]], "<eof>")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -238,7 +238,7 @@ test("[test-suite] literals: Error in escape sequences", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -260,7 +260,7 @@ test("[test-suite] literals: valid characters in variable names", function (t) {
not load("a" .. s .. "1 = 1", ""))
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -269,7 +269,7 @@ test("[test-suite] literals: valid characters in variable names", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -295,7 +295,7 @@ test("[test-suite] literals: long variable names", function (t) {
assert(_G[var1] == 5 and _G[var2] == 6 and f() == -1)
var1, var2, f = nil
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -304,7 +304,7 @@ test("[test-suite] literals: long variable names", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(dostring + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode));
}, "Lua program loaded without error");
@@ -321,7 +321,7 @@ test("[test-suite] literals: escapes", function (t) {
let luaCode = `assert("\\n\\t" == [[\n\n\t]])
assert([[\n\n $debug]] == "\\n $debug")
assert([[ [ ]] ~= [[ ] ]])`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -330,7 +330,7 @@ assert([[ [ ]] ~= [[ ] ]])`, L;
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(dostring + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode));
}, "Lua program loaded without error");
@@ -396,7 +396,7 @@ assert(x)
prog = nil
a = nil
b = nil`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -405,7 +405,7 @@ b = nil`, L;
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(dostring + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode));
}, "Lua program loaded without error");
@@ -438,7 +438,7 @@ for _, n in pairs{"\\n", "\\r", "\\n\\r", "\\r\\n"} do
assert(dostring(prog) == nn)
assert(_G.x == "hi\\n" and _G.y == "\\nhello\\r\\n\\n")
end`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -447,7 +447,7 @@ end`, L;
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(dostring + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode));
}, "Lua program loaded without error");
@@ -480,7 +480,7 @@ x y z [==[ blu foo
]
]=]==]
error error]=]===]`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -489,7 +489,7 @@ error error]=]===]`, L;
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(dostring + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode));
}, "Lua program loaded without error");
@@ -518,7 +518,7 @@ end
for s in coroutine.wrap(function () gen("", len) end) do
assert(s == load("return [====[\\n"..s.."]====]", "")())
end`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -527,7 +527,7 @@ end`, L;
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(dostring + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode));
}, "Lua program loaded without error");
@@ -547,7 +547,7 @@ test("[test-suite] literals: testing %q x line ends", function (t) {
local c = string.format("return %q", s)
assert(assert(load(c))() == s)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -556,7 +556,7 @@ test("[test-suite] literals: testing %q x line ends", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(dostring + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode));
}, "Lua program loaded without error");
@@ -577,7 +577,7 @@ test("[test-suite] literals: testing errors", function (t) {
assert(not load"a = '\\\\345'")
assert(not load"a = [=x]")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -586,7 +586,7 @@ test("[test-suite] literals: testing errors", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(dostring + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode));
}, "Lua program loaded without error");
diff --git a/tests/test-suite/locals.js b/tests/test-suite/locals.js
index cc82e38..d1dc3e4 100644
--- a/tests/test-suite/locals.js
+++ b/tests/test-suite/locals.js
@@ -5,7 +5,7 @@ const test = require('tape');
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
const lualib = require('../../src/lualib.js');
-
+const {to_luastring} = require("../../src/fengaricore.js");
test('[test-suite] locals: bug in 5.1', function (t) {
let luaCode = `
@@ -18,7 +18,7 @@ test('[test-suite] locals: bug in 5.1', function (t) {
local function f(x) x = nil; local y; return x, y end
assert(f(10) == nil and select(2, f(20)) == nil)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -27,7 +27,7 @@ test('[test-suite] locals: bug in 5.1', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -90,7 +90,7 @@ test('[test-suite] locals: local scope', function (t) {
f(2)
assert(type(f) == 'function')
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -99,7 +99,7 @@ test('[test-suite] locals: local scope', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -130,7 +130,7 @@ test('[test-suite] locals: test for global table of loaded chunks', function (t)
f()
assert(c.a == 3)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -139,7 +139,7 @@ test('[test-suite] locals: test for global table of loaded chunks', function (t)
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(getenv + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(getenv + luaCode));
}, "Lua program loaded without error");
@@ -173,7 +173,7 @@ test('[test-suite] locals: old test for limits for special instructions (now jus
until p <= 0
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -182,7 +182,7 @@ test('[test-suite] locals: old test for limits for special instructions (now jus
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -202,7 +202,7 @@ test('[test-suite] locals: testing lexical environments', function (t) {
do
local dummy
local _ENV = (function (...) return ... end)(_G, dummy) -- {
-
+
do local _ENV = {assert=assert}; assert(true) end
mt = {_G = _G}
local foo,x
@@ -217,7 +217,7 @@ test('[test-suite] locals: testing lexical environments', function (t) {
assert(getenv(foo) == mt)
x = foo('hi'); assert(mt.A == 'hi' and A == 1000)
assert(x('*') == mt.A .. '*')
-
+
do local _ENV = {assert=assert, A=10};
do local _ENV = {assert=assert, A=20};
assert(A==20);x=A
@@ -227,7 +227,7 @@ test('[test-suite] locals: testing lexical environments', function (t) {
assert(x==20)
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -236,7 +236,7 @@ test('[test-suite] locals: testing lexical environments', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(getenv + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(getenv + luaCode));
}, "Lua program loaded without error");
diff --git a/tests/test-suite/ltests.js b/tests/test-suite/ltests.js
index 08bb603..11de5c3 100644
--- a/tests/test-suite/ltests.js
+++ b/tests/test-suite/ltests.js
@@ -4,6 +4,7 @@ const assert = require("assert");
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
+const {luastring_indexOf, to_jsstring, to_luastring} = require("../../src/fengaricore.js");
const ljstype = require('../../src/ljstype.js');
const lopcodes = require('../../src/lopcodes.js');
const sprintf = require('sprintf-js').sprintf;
@@ -40,7 +41,7 @@ const getnum = function(L, L1, pc) {
pc.offset++;
}
if (!ljstype.lisdigit(pc.script[pc.offset]))
- lauxlib.luaL_error(L, lua.to_luastring("number expected (%s)"), pc.script);
+ lauxlib.luaL_error(L, to_luastring("number expected (%s)"), pc.script);
while (ljstype.lisdigit(pc.script[pc.offset])) res = res*10 + pc.script[pc.offset++] - '0'.charCodeAt(0);
return sig*res;
};
@@ -52,7 +53,7 @@ const getstring = function(L, buff, pc) {
let quote = pc.script[pc.offset++];
while (pc.script[pc.offset] !== quote) {
if (pc.script[pc.offset] === 0 || pc.offset >= pc.script.length)
- lauxlib.luaL_error(L, lua.to_luastring("unfinished string in JS script", true));
+ lauxlib.luaL_error(L, to_luastring("unfinished string in JS script", true));
buff[i++] = pc.script[pc.offset++];
}
pc.offset++;
@@ -67,13 +68,13 @@ const getindex = function(L, L1, pc) {
skip(pc);
switch (pc.script[pc.offset++]) {
case 'R'.charCodeAt(0): return lua.LUA_REGISTRYINDEX;
- case 'G'.charCodeAt(0): return lauxlib.luaL_error(L, lua.to_luastring("deprecated index 'G'", true));
+ case 'G'.charCodeAt(0): return lauxlib.luaL_error(L, to_luastring("deprecated index 'G'", true));
case 'U'.charCodeAt(0): return lua.lua_upvalueindex(getnum(L, L1, pc));
default: pc.offset--; return getnum(L, L1, pc);
}
};
-const codes = ["OK", "YIELD", "ERRRUN", "ERRSYNTAX", "ERRMEM", "ERRGCMM", "ERRERR"].map(e => lua.to_luastring(e));
+const codes = ["OK", "YIELD", "ERRRUN", "ERRSYNTAX", "ERRMEM", "ERRGCMM", "ERRERR"].map(e => to_luastring(e));
const pushcode = function(L, code) {
lua.lua_pushstring(L, codes[code]);
@@ -82,7 +83,7 @@ const pushcode = function(L, code) {
const printstack = function(L) {
let n = lua.lua_gettop(L);
for (let i = 1; i <= n; i++) {
- console.log("${i}: %{lua.to_jsstring(lauxlib.luaL_tolstring(L, i, null))}\n");
+ console.log("${i}: %{to_jsstring(lauxlib.luaL_tolstring(L, i, null))}\n");
lua.lua_pop(L, 1);
}
console.log("");
@@ -101,9 +102,9 @@ const ops = "+-*%^/\\&|~<>_!".split('').map(e => e.charCodeAt(0));
const runJS = function(L, L1, pc) {
let buff = new Uint8Array(300);
let status = 0;
- if (!pc || !pc.script) return lauxlib.luaL_error(L, lua.to_luastring("attempt to runJS null script"));
+ if (!pc || !pc.script) return lauxlib.luaL_error(L, to_luastring("attempt to runJS null script"));
for (;;) {
- let inst = lua.to_jsstring(getstring(L, buff, pc));
+ let inst = to_jsstring(getstring(L, buff, pc));
if (inst.length === 0) return 0;
switch (inst) {
case "absindex": {
@@ -475,7 +476,7 @@ const runJS = function(L, L1, pc) {
return lua.lua_yieldk(L1, nres, i, Cfunck);
}
default:
- lauxlib.luaL_error(L, lua.to_luastring("unknown instruction %s"), buff);
+ lauxlib.luaL_error(L, to_luastring("unknown instruction %s"), buff);
}
}
};
@@ -552,7 +553,7 @@ const newstate = function(L) {
const getstate = function(L) {
let L1 = lua.lua_touserdata(L, 1);
- lauxlib.luaL_argcheck(L, L1 !== null, 1, lua.to_luastring("state expected", true));
+ lauxlib.luaL_argcheck(L, L1 !== null, 1, to_luastring("state expected", true));
return L1;
};
@@ -578,16 +579,16 @@ const loadlib = function(L) {
"table": luaopen_table
};
let L1 = getstate(L);
- lauxlib.luaL_requiref(L1, lua.to_luastring("package", true), luaopen_package, 0);
+ lauxlib.luaL_requiref(L1, to_luastring("package", true), luaopen_package, 0);
assert(lua.lua_type(L1, -1) == lua.LUA_TTABLE);
/* 'requiref' should not reload module already loaded... */
- lauxlib.luaL_requiref(L1, lua.to_luastring("package", true), null, 1); /* seg. fault if it reloads */
+ lauxlib.luaL_requiref(L1, to_luastring("package", true), null, 1); /* seg. fault if it reloads */
/* ...but should return the same module */
assert(lua.lua_compare(L1, -1, -2, lua.LUA_OPEQ));
lauxlib.luaL_getsubtable(L1, lua.LUA_REGISTRYINDEX, lauxlib.LUA_PRELOAD_TABLE);
for (let name in libs) {
lua.lua_pushcfunction(L1, libs[name]);
- lua.lua_setfield(L1, -2, lua.to_luastring(name, true));
+ lua.lua_setfield(L1, -2, to_luastring(name, true));
}
return 0;
};
@@ -637,8 +638,8 @@ const newuserdata = function(L) {
*/
const Chook = function(L, ar) {
let scpt;
- let events = ["call", "ret", "line", "count", "tailcall"].map(e => lua.to_luastring(e));
- lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, lua.to_luastring("JS_HOOK", true));
+ let events = ["call", "ret", "line", "count", "tailcall"].map(e => to_luastring(e));
+ lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, to_luastring("JS_HOOK", true));
lua.lua_pushlightuserdata(L, L);
lua.lua_gettable(L, -2); /* get C_HOOK[L] (script saved by sethookaux) */
scpt = lua.lua_tostring(L, -1); /* not very religious (string will be popped) */
@@ -661,7 +662,7 @@ class Aux {
const panicback = function(L) {
let b = new Aux();
lua.lua_checkstack(L, 1); /* open space for 'Aux' struct */
- lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, lua.to_luastring("_jmpbuf", true)); /* get 'Aux' struct */
+ lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, to_luastring("_jmpbuf", true)); /* get 'Aux' struct */
b = lua.lua_touserdata(L, -1);
lua.lua_pop(L, 1); /* remove 'Aux' struct */
runJS(b.L, L, { script: b.paniccode, offset: 0 }); /* run optional panic code */
@@ -671,7 +672,7 @@ const panicback = function(L) {
const checkpanic = function(L) {
let b = new Aux();
let code = lauxlib.luaL_checkstring(L, 1);
- b.paniccode = lauxlib.luaL_optstring(L, 2, lua.to_luastring("", true));
+ b.paniccode = lauxlib.luaL_optstring(L, 2, to_luastring("", true));
b.L = L;
let L1 = lua.lua_newstate(); /* create new state */
if (L1 === null) { /* error? */
@@ -680,7 +681,7 @@ const checkpanic = function(L) {
}
lua.lua_atpanic(L1, panicback); /* set its panic function */
lua.lua_pushlightuserdata(L1, b);
- lua.lua_setfield(L1, lua.LUA_REGISTRYINDEX, lua.to_luastring("_jmpbuf", true)); /* store 'Aux' struct */
+ lua.lua_setfield(L1, lua.LUA_REGISTRYINDEX, to_luastring("_jmpbuf", true)); /* store 'Aux' struct */
try { /* set jump buffer */
runJS(L, L1, { script: code, offset: 0 }); /* run code unprotected */
lua.lua_pushliteral(L, "no errors");
@@ -700,12 +701,12 @@ const sethookaux = function(L, mask, count, scpt) {
lua.lua_sethook(L, null, 0, 0); /* turn off hooks */
return;
}
- lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, lua.to_luastring("JS_HOOK", true)); /* get C_HOOK table */
+ lua.lua_getfield(L, lua.LUA_REGISTRYINDEX, to_luastring("JS_HOOK", true)); /* get C_HOOK table */
if (!lua.lua_istable(L, -1)) { /* no hook table? */
lua.lua_pop(L, 1); /* remove previous value */
lua.lua_newtable(L); /* create new C_HOOK table */
lua.lua_pushvalue(L, -1);
- lua.lua_setfield(L, lua.LUA_REGISTRYINDEX, lua.to_luastring("JS_HOOK", true)); /* register it */
+ lua.lua_setfield(L, lua.LUA_REGISTRYINDEX, to_luastring("JS_HOOK", true)); /* register it */
}
lua.lua_pushlightuserdata(L, L);
lua.lua_pushstring(L, scpt);
@@ -721,9 +722,9 @@ const sethook = function(L) {
const smask = lauxlib.luaL_checkstring(L, 2);
let count = lauxlib.luaL_optinteger(L, 3, 0);
let mask = 0;
- if (smask.indexOf('c'.charCodeAt(0)) >= 0) mask |= lua.LUA_MASKCALL;
- if (smask.indexOf('r'.charCodeAt(0)) >= 0) mask |= lua.LUA_MASKRET;
- if (smask.indexOf('l'.charCodeAt(0)) >= 0) mask |= lua.LUA_MASKLINE;
+ if (luastring_indexOf(smask, 'c'.charCodeAt(0)) >= 0) mask |= lua.LUA_MASKCALL;
+ if (luastring_indexOf(smask, 'r'.charCodeAt(0)) >= 0) mask |= lua.LUA_MASKRET;
+ if (luastring_indexOf(smask, 'l'.charCodeAt(0)) >= 0) mask |= lua.LUA_MASKLINE;
if (count > 0) mask |= lua.LUA_MASKCOUNT;
sethookaux(L, mask, count, scpt);
}
@@ -736,9 +737,9 @@ const Cfunc = function(L) {
const Cfunck = function(L, status, ctx) {
pushcode(L, status);
- lua.lua_setglobal(L, lua.to_luastring("status", true));
+ lua.lua_setglobal(L, to_luastring("status", true));
lua.lua_pushinteger(L, ctx);
- lua.lua_setglobal(L, lua.to_luastring("ctx", true));
+ lua.lua_setglobal(L, to_luastring("ctx", true));
return runJS(L, L, { script: lua.lua_tostring(L, ctx), offset: 0 });
};
@@ -751,7 +752,7 @@ const makeCfunc = function(L) {
const coresume = function(L) {
let status;
let co = lua.lua_tothread(L, 1);
- lauxlib.luaL_argcheck(L, co, 1, lua.to_luastring("coroutine expected", true));
+ lauxlib.luaL_argcheck(L, co, 1, to_luastring("coroutine expected", true));
status = lua.lua_resume(co, L, 0);
if (status != lua.LUA_OK && status !== lua.LUA_YIELD) {
lua.lua_pushboolean(L, 0);
@@ -800,16 +801,16 @@ const buildop = function(p, pc) {
break;
}
- return lua.to_luastring(result);
+ return to_luastring(result);
};
const listcode = function(L) {
lauxlib.luaL_argcheck(L, lua.lua_isfunction(L, 1) && !lua.lua_iscfunction(L, 1),
- 1, lua.to_luastring("Lua function expected", true));
+ 1, to_luastring("Lua function expected", true));
let p = obj_at(L, 1);
lua.lua_newtable(L);
- setnameval(L, lua.to_luastring("maxstack", true), p.maxstacksize);
- setnameval(L, lua.to_luastring("numparams", true), p.numparams);
+ setnameval(L, to_luastring("maxstack", true), p.maxstacksize);
+ setnameval(L, to_luastring("numparams", true), p.numparams);
for (let pc = 0; pc < p.code.length; pc++) {
lua.lua_pushinteger(L, pc+1);
lua.lua_pushstring(L, buildop(p, pc));
@@ -821,7 +822,7 @@ const listcode = function(L) {
const listk = function(L) {
lauxlib.luaL_argcheck(L,
lua.lua_isfunction(L, 1) && !lua.lua_iscfunction(L, 1),
- 1, lua.to_luastring("Lua function expected"), true);
+ 1, to_luastring("Lua function expected"), true);
let p = obj_at(L, 1);
lua.lua_createtable(L, p.k.length, 0);
for (let i = 0; i < p.k.length; i++) {
@@ -859,7 +860,7 @@ const luaB_opentests = function(L) {
};
const luaopen_tests = function(L) {
- lauxlib.luaL_requiref(L, lua.to_luastring("T"), luaB_opentests, 1);
+ lauxlib.luaL_requiref(L, to_luastring("T"), luaB_opentests, 1);
lua.lua_pop(L, 1); /* remove lib */
};
diff --git a/tests/test-suite/math.js b/tests/test-suite/math.js
index 0052bc2..9fb6fa5 100644
--- a/tests/test-suite/math.js
+++ b/tests/test-suite/math.js
@@ -5,7 +5,7 @@ const test = require('tape');
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
const lualib = require('../../src/lualib.js');
-
+const {to_luastring} = require("../../src/fengaricore.js");
const prefix = `
local minint = math.mininteger
@@ -59,7 +59,7 @@ test("[test-suite] math: int bits", function (t) {
assert(minint == 1 << (intbits - 1))
assert(maxint == minint - 1)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -68,7 +68,7 @@ test("[test-suite] math: int bits", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -98,7 +98,7 @@ test("[test-suite] math: number of bits in the mantissa of a floating-point numb
assert(math.type(0) == "integer" and math.type(0.0) == "float"
and math.type("10") == nil)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -107,7 +107,7 @@ test("[test-suite] math: number of bits in the mantissa of a floating-point numb
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -162,7 +162,7 @@ test("[test-suite] math: basic float notation", function (t) {
assert(eqT(a, minint) and eqT(b, 0.0))
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -171,7 +171,7 @@ test("[test-suite] math: basic float notation", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -189,7 +189,7 @@ test("[test-suite] math: math.huge", function (t) {
assert(math.huge > 10e30)
assert(-math.huge < -10e30)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -198,7 +198,7 @@ test("[test-suite] math: math.huge", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -219,7 +219,7 @@ test("[test-suite] math: integer arithmetic", function (t) {
assert(minint * minint == 0)
assert(maxint * maxint * maxint == maxint)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -228,7 +228,7 @@ test("[test-suite] math: integer arithmetic", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -274,7 +274,7 @@ test("[test-suite] math: testing floor division and conversions", function (t) {
assert(minint // -2 == 2^(intbits - 2))
assert(maxint // -1 == -maxint)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -283,7 +283,7 @@ test("[test-suite] math: testing floor division and conversions", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -311,7 +311,7 @@ test("[test-suite] math: negative exponents", function (t) {
end
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -320,7 +320,7 @@ test("[test-suite] math: negative exponents", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -351,7 +351,7 @@ test("[test-suite] math: comparison between floats and integers (border cases)",
assert(minint + 0.0 == minint)
assert(minint + 0.0 == -2.0^(intbits - 1))
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -360,7 +360,7 @@ test("[test-suite] math: comparison between floats and integers (border cases)",
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -460,7 +460,7 @@ test("[test-suite] math: order between floats and integers", function (t) {
assert(not (minint < NaN))
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -469,7 +469,7 @@ test("[test-suite] math: order between floats and integers", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -491,7 +491,7 @@ test("[test-suite] math: avoiding errors at compile time", function (t) {
checkcompt(msgf2i, ("return 1 | 2.0^%d"):format(intbits - 1))
checkcompt(msgf2i, "return 2.3 ~ '0.0'")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -500,7 +500,7 @@ test("[test-suite] math: avoiding errors at compile time", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -544,7 +544,7 @@ test("[test-suite] math: testing overflow errors when converting from float to i
-- 'minint' should be representable as a float no matter the precision
assert(f2i(minint + 0.0) == minint)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -553,7 +553,7 @@ test("[test-suite] math: testing overflow errors when converting from float to i
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -573,7 +573,7 @@ test("[test-suite] math: testing numeric strings", function (t) {
assert(" -2 " + 1 == -1)
assert(" -0xa " + 1 == -9)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -582,7 +582,7 @@ test("[test-suite] math: testing numeric strings", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -631,7 +631,7 @@ test("[test-suite] math: Literal integer Overflows (new behavior in 5.3.3)", fun
assert(eqT(-10000000000000000000000.0, -10000000000000000000000))
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -640,7 +640,7 @@ test("[test-suite] math: Literal integer Overflows (new behavior in 5.3.3)", fun
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -660,7 +660,7 @@ test("[test-suite] math: 'tonumber' with numbers", function (t) {
assert(eqT(tonumber(maxint), maxint) and eqT(tonumber(minint), minint))
assert(tonumber(1/0) == 1/0)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -669,7 +669,7 @@ test("[test-suite] math: 'tonumber' with numbers", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -722,7 +722,7 @@ test("[test-suite] math: 'tonumber' with strings", function (t) {
assert(tonumber('\\t10000000000\\t', i) == i10)
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -731,7 +731,7 @@ test("[test-suite] math: 'tonumber' with strings", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -760,7 +760,7 @@ test("[test-suite] math: tests with very long numerals", function (t) {
assert(tonumber('0xe03' .. string.rep('0', 1000) .. 'p-4000') == 3587.0)
assert(tonumber('0x.' .. string.rep('0', 1000) .. '74p4004') == 0x7.4)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -769,7 +769,7 @@ test("[test-suite] math: tests with very long numerals", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -816,7 +816,7 @@ test("[test-suite] math: testing 'tonumber' for invalid formats", function (t) {
assert(f(tonumber('e 1')) == nil)
assert(f(tonumber(' 3.4.5 ')) == nil)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -825,7 +825,7 @@ test("[test-suite] math: testing 'tonumber' for invalid formats", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -853,7 +853,7 @@ test("[test-suite] math: testing 'tonumber' for invalid hexadecimal formats", fu
assert(tonumber('0x0.51p') == nil)
assert(tonumber('0x5p+-2') == nil)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -862,7 +862,7 @@ test("[test-suite] math: testing 'tonumber' for invalid hexadecimal formats", fu
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -887,7 +887,7 @@ test("[test-suite] math: testing hexadecimal numerals", function (t) {
-- possible confusion with decimal exponent
assert(0E+1 == 0 and 0xE+1 == 15 and 0xe-1 == 13)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -896,7 +896,7 @@ test("[test-suite] math: testing hexadecimal numerals", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -935,7 +935,7 @@ test("[test-suite] math: floating hexas", function (t) {
assert(tonumber('+1.23E18') == 1.23*10.0^18)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -944,7 +944,7 @@ test("[test-suite] math: floating hexas", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -969,7 +969,7 @@ test("[test-suite] math: testing order operators", function (t) {
assert(('a'>='a') and not('a'>='b') and ('b'>='a'))
assert(1.3 < 1.4 and 1.3 <= 1.4 and not (1.3 < 1.3) and 1.3 <= 1.3)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -978,7 +978,7 @@ test("[test-suite] math: testing order operators", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1010,7 +1010,7 @@ test("[test-suite] math: testing mod operator", function (t) {
assert(minint % -2 == 0)
assert(maxint % -2 == -1)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1019,7 +1019,7 @@ test("[test-suite] math: testing mod operator", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1047,7 +1047,7 @@ test("[test-suite] math: non-portable tests because Windows C library cannot com
assert(-1 % math.huge == math.huge)
assert(-1 % -math.huge == -1)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1056,7 +1056,7 @@ test("[test-suite] math: non-portable tests because Windows C library cannot com
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1103,7 +1103,7 @@ test("[test-suite] math: testing unsigned comparisons", function (t) {
assert(tonumber(' 1.3e-2 ') == 1.3e-2)
assert(tonumber(' -1.00000000000001 ') == -1.00000000000001)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1112,7 +1112,7 @@ test("[test-suite] math: testing unsigned comparisons", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1131,7 +1131,7 @@ test("[test-suite] math: testing constant limits", function (t) {
assert(8388608 + -8388608 == 0)
assert(8388607 + -8388607 == 0)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1140,7 +1140,7 @@ test("[test-suite] math: testing constant limits", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1198,7 +1198,7 @@ test("[test-suite] math: testing floor & ceil", function (t) {
assert(math.tointeger(0/0) == nil) -- NaN
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1207,7 +1207,7 @@ test("[test-suite] math: testing floor & ceil", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1242,7 +1242,7 @@ test("[test-suite] math: testing fmod for integers", function (t) {
checkerror("zero", math.fmod, 3, 0)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1251,7 +1251,7 @@ test("[test-suite] math: testing fmod for integers", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1282,7 +1282,7 @@ test("[test-suite] math: testing max/min", function (t) {
assert(eqT(math.min(maxint - 2, maxint, maxint - 1), maxint - 2))
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1291,7 +1291,7 @@ test("[test-suite] math: testing max/min", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1310,7 +1310,7 @@ test("[test-suite] math: testing implicit convertions", function (t) {
assert(a*b == 200 and a+b == 30 and a-b == -10 and a/b == 0.5 and -b == -20)
assert(a == '10' and b == '20')
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1319,7 +1319,7 @@ test("[test-suite] math: testing implicit convertions", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1369,7 +1369,7 @@ test("[test-suite] math: testing -0 and NaN", function (t) {
assert(a3 == a5)
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1378,7 +1378,7 @@ test("[test-suite] math: testing -0 and NaN", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1410,7 +1410,7 @@ test("[test-suite] math: test random for floats", function (t) {
::ok::
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1419,7 +1419,7 @@ test("[test-suite] math: test random for floats", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1466,7 +1466,7 @@ test("[test-suite] math: test random for small intervals", function (t) {
aux({maxint - 3, maxint})
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1475,7 +1475,7 @@ test("[test-suite] math: test random for small intervals", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1524,7 +1524,7 @@ test("[test-suite] math: test random for large intervals", function (t) {
assert(not pcall(math.random, 1, 2, 3)) -- too many arguments
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1533,7 +1533,7 @@ test("[test-suite] math: test random for large intervals", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1552,7 +1552,7 @@ test("[test-suite] math: test random for empty interval", function (t) {
assert(not pcall(math.random, maxint, maxint - 1))
assert(not pcall(math.random, maxint, minint))
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1561,7 +1561,7 @@ test("[test-suite] math: test random for empty interval", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1580,7 +1580,7 @@ test("[test-suite] math: interval too large", function (t) {
assert(not pcall(math.random, -1, maxint))
assert(not pcall(math.random, minint // 2, maxint // 2 + 1))
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1589,7 +1589,7 @@ test("[test-suite] math: interval too large", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
diff --git a/tests/test-suite/nextvar.js b/tests/test-suite/nextvar.js
index ad75f93..3e05490 100644
--- a/tests/test-suite/nextvar.js
+++ b/tests/test-suite/nextvar.js
@@ -5,7 +5,7 @@ const test = require('tape');
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
const lualib = require('../../src/lualib.js');
-
+const {to_luastring} = require("../../src/fengaricore.js");
const prefix = `
local function checkerror (msg, f, ...)
@@ -27,7 +27,7 @@ test("[test-suite] nextvar: testing size operator", function (t) {
assert(#a == i)
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -36,7 +36,7 @@ test("[test-suite] nextvar: testing size operator", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -59,7 +59,7 @@ test("[test-suite] nextvar: testing ipairs", function (t) {
for _ in ipairs{x=12, y=24} do assert(nil) end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -68,7 +68,7 @@ test("[test-suite] nextvar: testing ipairs", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -92,7 +92,7 @@ test("[test-suite] nextvar: test for 'false' x ipair", function (t) {
end
assert(i == 4)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -101,7 +101,7 @@ test("[test-suite] nextvar: test for 'false' x ipair", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -118,7 +118,7 @@ test("[test-suite] nextvar: iterator function is always the same", function (t)
let luaCode = `
assert(type(ipairs{}) == 'function' and ipairs{} == ipairs{})
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -127,7 +127,7 @@ test("[test-suite] nextvar: iterator function is always the same", function (t)
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -171,7 +171,7 @@ test("[test-suite] nextvar: JS tests", { skip: true }, function (t) {
a = math.ceil(a*1.3)
end
-
+
local function check (t, na, nh)
local a, h = T.querytab(t)
if a ~= na or h ~= nh then
@@ -195,7 +195,7 @@ test("[test-suite] nextvar: JS tests", { skip: true }, function (t) {
for i=1,lim do
s = s..i..','
local s = s
- for k=0,lim do
+ for k=0,lim do
local t = load(s..'}', '')()
assert(#t == i)
check(t, fb(i), mp2(k))
@@ -272,7 +272,7 @@ test("[test-suite] nextvar: JS tests", { skip: true }, function (t) {
local a = {}
for i=1,lim do a[i] = true; foo(i, table.unpack(a)) end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -281,7 +281,7 @@ test("[test-suite] nextvar: JS tests", { skip: true }, function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -302,7 +302,7 @@ test("[test-suite] nextvar: test size operation on empty tables", function (t) {
assert(#{nil, nil, nil} == 0)
assert(#{nil, nil, nil, nil} == 0)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -311,7 +311,7 @@ test("[test-suite] nextvar: test size operation on empty tables", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -332,7 +332,7 @@ test("[test-suite] nextvar: test size operation on empty tables", function (t) {
assert(#{nil, nil, nil} == 0)
assert(#{nil, nil, nil, nil} == 0)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -341,7 +341,7 @@ test("[test-suite] nextvar: test size operation on empty tables", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -393,7 +393,7 @@ test("[test-suite] nextvar: next uses always the same iteration function", funct
_G["xxx"] = 1
assert(xxx==find("xxx"))
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -402,7 +402,7 @@ test("[test-suite] nextvar: next uses always the same iteration function", funct
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -419,7 +419,7 @@ test("[test-suite] nextvar: invalid key to 'next'", function (t) {
let luaCode = `
checkerror("invalid key", next, {10,20}, 3)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -428,7 +428,7 @@ test("[test-suite] nextvar: invalid key to 'next'", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -446,7 +446,7 @@ test("[test-suite] nextvar: both 'pairs' and 'ipairs' need an argument", functio
checkerror("bad argument", pairs)
checkerror("bad argument", ipairs)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -455,7 +455,7 @@ test("[test-suite] nextvar: both 'pairs' and 'ipairs' need an argument", functio
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -485,7 +485,7 @@ test("[test-suite] nextvar: fmod table", function (t) {
assert(n.n == 9000)
a = nil
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -494,7 +494,7 @@ test("[test-suite] nextvar: fmod table", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -522,7 +522,7 @@ test("[test-suite] nextvar: check next", function (t) {
checknext{1,2,3,4,x=1,y=2,z=3}
checknext{1,2,3,4,5,x=1,y=2,z=3}
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -531,7 +531,7 @@ test("[test-suite] nextvar: check next", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -555,7 +555,7 @@ test("[test-suite] nextvar: # operator", function (t) {
assert(#a == i)
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -564,7 +564,7 @@ test("[test-suite] nextvar: # operator", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -596,7 +596,7 @@ test("[test-suite] nextvar: maxn", function (t) {
table.maxn = nil
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -605,7 +605,7 @@ test("[test-suite] nextvar: maxn", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -624,7 +624,7 @@ test("[test-suite] nextvar: int overflow", function (t) {
for i=0,50 do a[2^i] = true end
assert(a[#a])
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -633,7 +633,7 @@ test("[test-suite] nextvar: int overflow", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -721,7 +721,7 @@ test("[test-suite] nextvar: erasing values", function (t) {
assert(table.remove(a, 2) == 20)
assert(a[#a] == 30 and #a == 2)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -730,7 +730,7 @@ test("[test-suite] nextvar: erasing values", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -791,7 +791,7 @@ test("[test-suite] nextvar: testing table library with metamethods", function (t
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -800,7 +800,7 @@ test("[test-suite] nextvar: testing table library with metamethods", function (t
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -839,12 +839,12 @@ test("[test-suite] nextvar: JS tests", { skip: true }, function (t) {
mt.__newindex = nil
mt.__len = nil
local tab2 = {}
- local u2 = T.newuserdata(0)
+ local u2 = T.newuserdata(0)
debug.setmetatable(u2, {__newindex = function (_, k, v) tab2[k] = v end})
table.move(u, 1, 4, 1, u2)
assert(#tab2 == 4 and tab2[1] == tab[1] and tab2[4] == tab[4])
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -853,7 +853,7 @@ test("[test-suite] nextvar: JS tests", { skip: true }, function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -883,7 +883,7 @@ test("[test-suite] nextvar: next", function (t) {
a = nil; for i=1,1 do assert(not a); a=1 end; assert(a)
a = nil; for i=1,1,-1 do assert(not a); a=1 end; assert(a)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -892,7 +892,7 @@ test("[test-suite] nextvar: next", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -926,7 +926,7 @@ test("[test-suite] nextvar: testing floats in numeric for", function (t) {
a = 0; for i=1.0, 0.99999, -1 do a=a+1 end; assert(a==1)
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -935,7 +935,7 @@ test("[test-suite] nextvar: testing floats in numeric for", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -952,7 +952,7 @@ test("[test-suite] nextvar: conversion", function (t) {
let luaCode = `
a = 0; for i="10","1","-2" do a=a+1 end; assert(a==5)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -961,7 +961,7 @@ test("[test-suite] nextvar: conversion", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1030,7 +1030,7 @@ test("[test-suite] nextvar: checking types", function (t) {
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1039,7 +1039,7 @@ test("[test-suite] nextvar: checking types", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1071,7 +1071,7 @@ test("[test-suite] nextvar: testing generic 'for'", function (t) {
end
assert(x == 5)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1080,7 +1080,7 @@ test("[test-suite] nextvar: testing generic 'for'", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1123,7 +1123,7 @@ test("[test-suite] nextvar: testing __pairs and __ipairs metamethod", function (
a.n = 5
a[3] = 30
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1132,7 +1132,7 @@ test("[test-suite] nextvar: testing __pairs and __ipairs metamethod", function (
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -1149,7 +1149,7 @@ test("[test-suite] nextvar: testing ipairs with metamethods", function (t) {
let luaCode = `
a = {n=10}
setmetatable(a, { __index = function (t,k)
- if k <= t.n then return k * 10 end
+ if k <= t.n then return k * 10 end
end})
i = 0
for k,v in ipairs(a) do
@@ -1158,7 +1158,7 @@ test("[test-suite] nextvar: testing ipairs with metamethods", function (t) {
end
assert(i == a.n)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -1167,7 +1167,7 @@ test("[test-suite] nextvar: testing ipairs with metamethods", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
diff --git a/tests/test-suite/pm.js b/tests/test-suite/pm.js
index ae3512e..214d498 100644
--- a/tests/test-suite/pm.js
+++ b/tests/test-suite/pm.js
@@ -5,7 +5,7 @@ const test = require('tape');
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
const lualib = require('../../src/lualib.js');
-
+const {to_luastring} = require("../../src/fengaricore.js");
test("[test-suite] pm: pattern matching", function (t) {
let luaCode = `
@@ -86,7 +86,7 @@ test("[test-suite] pm: pattern matching", function (t) {
assert(f("0alo alo", "%x*") == "0a")
assert(f("alo alo", "%C+") == "alo alo")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -95,7 +95,7 @@ test("[test-suite] pm: pattern matching", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -125,7 +125,7 @@ test("[test-suite] pm: tonumber", function (t) {
-- assert(f1('=======', '^(=*)=%1$') == '=======')
assert(string.match('==========', '^([=]*)=%1$') == nil)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -134,7 +134,7 @@ test("[test-suite] pm: tonumber", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -177,7 +177,7 @@ test("[test-suite] pm: range", function (t) {
assert(strset('%Z') == strset('[\\1-\\255]'))
assert(strset('.') == strset('[\\1-\\255%z]'))
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -186,7 +186,7 @@ test("[test-suite] pm: range", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -210,7 +210,7 @@ test("[test-suite] pm: classes", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadfile(L, lua.to_luastring("tests/test-suite/pm-classes.lua"));
+ lauxlib.luaL_loadfile(L, to_luastring("tests/test-suite/pm-classes.lua"));
}, "Lua program loaded without error");
@@ -234,7 +234,7 @@ test("[test-suite] pm: gsub", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadfile(L, lua.to_luastring("tests/test-suite/pm-gsub.lua"));
+ lauxlib.luaL_loadfile(L, to_luastring("tests/test-suite/pm-gsub.lua"));
}, "Lua program loaded without error");
@@ -262,7 +262,7 @@ test("[test-suite] pm: empty matches", function (t) {
assert(res == "-a-b-c-d-")
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -271,7 +271,7 @@ test("[test-suite] pm: empty matches", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -316,7 +316,7 @@ test("[test-suite] pm: gsub", function (t) {
end)
assert(s == r and t[1] == 1 and t[3] == 3 and t[7] == 4 and t[13] == 4)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -325,7 +325,7 @@ test("[test-suite] pm: gsub", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -348,7 +348,7 @@ test("[test-suite] pm: gsub isbalanced", function (t) {
assert(not isbalanced("(9 ((8) 7) a b (\\0 c) a"))
assert(string.gsub("alo 'oi' alo", "%b''", '"') == 'alo " alo')
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -357,7 +357,7 @@ test("[test-suite] pm: gsub isbalanced", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -397,7 +397,7 @@ test("[test-suite] pm: capture", function (t) {
checkerror("invalid capture index %%1", string.gsub, "alo", "(%1)", "a")
checkerror("invalid use of '%%'", string.gsub, "alo", ".", "%x")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -406,7 +406,7 @@ test("[test-suite] pm: capture", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -434,7 +434,7 @@ test("[test-suite] pm: bug since 2.5 (C-stack overflow) (TODO: _soft)", function
assert(not r and string.find(m, "too complex"))
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -443,7 +443,7 @@ test("[test-suite] pm: bug since 2.5 (C-stack overflow) (TODO: _soft)", function
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -471,7 +471,7 @@ test("[test-suite] pm: big strings (TODO: _soft)", function (t) {
assert(not pcall(string.gsub, a, 'b'))
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -480,7 +480,7 @@ test("[test-suite] pm: big strings (TODO: _soft)", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -502,7 +502,7 @@ test("[test-suite] pm: recursive nest of gsubs", function (t) {
local x = "abcdef"
assert(rev(rev(x)) == x)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -511,7 +511,7 @@ test("[test-suite] pm: recursive nest of gsubs", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -536,7 +536,7 @@ test("[test-suite] pm: gsub with tables", function (t) {
t = {}; setmetatable(t, {__index = function (t,s) return string.upper(s) end})
assert(string.gsub("a alo b hi", "%w%w+", t) == "a ALO b HI")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -545,7 +545,7 @@ test("[test-suite] pm: gsub with tables", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -584,7 +584,7 @@ test("[test-suite] pm: gmatch", function (t) {
for k,v in pairs(t) do assert(k+1 == v+0); a=a+1 end
assert(a == 3)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -593,7 +593,7 @@ test("[test-suite] pm: gmatch", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -634,7 +634,7 @@ test("[test-suite] pm: tests for '%f' ('frontiers')", function (t) {
end
assert(#a == 0)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -643,7 +643,7 @@ test("[test-suite] pm: tests for '%f' ('frontiers')", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -676,7 +676,7 @@ test("[test-suite] pm: malformed patterns", function (t) {
malform("%")
malform("%f", "missing")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -685,7 +685,7 @@ test("[test-suite] pm: malformed patterns", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -708,7 +708,7 @@ test("[test-suite] pm: \\0 in patterns", function (t) {
assert(string.match("abc\\0\\0\\0", "%\\0+") == "\\0\\0\\0")
assert(string.match("abc\\0\\0\\0", "%\\0%\\0?") == "\\0\\0")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -717,7 +717,7 @@ test("[test-suite] pm: \\0 in patterns", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -735,7 +735,7 @@ test("[test-suite] pm: magic char after \\0", function (t) {
assert(string.find("abc\\0\\0","\\0.") == 4)
assert(string.find("abcx\\0\\0abc\\0abc","x\\0\\0abc\\0a.") == 4)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -744,7 +744,7 @@ test("[test-suite] pm: magic char after \\0", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
diff --git a/tests/test-suite/sort.js b/tests/test-suite/sort.js
index 9cee400..c52f30c 100644
--- a/tests/test-suite/sort.js
+++ b/tests/test-suite/sort.js
@@ -5,7 +5,7 @@ const test = require('tape');
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
const lualib = require('../../src/lualib.js');
-
+const {to_luastring} = require("../../src/fengaricore.js");
const prefix = `
local unpack = table.unpack
@@ -59,7 +59,7 @@ test("[test-suite] sort: testing unpack", function (t) {
a,x = unpack({1,2}, 1, 1)
assert(a==1 and x==nil)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -68,7 +68,7 @@ test("[test-suite] sort: testing unpack", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -111,7 +111,7 @@ test("[test-suite] sort: testing unpack", function (t) {
a, b = unpack(t, minI + 1, minI); assert(a == nil and b == nil)
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -120,7 +120,7 @@ test("[test-suite] sort: testing unpack", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -141,7 +141,7 @@ test("[test-suite] sort: testing unpack", function (t) {
checkerror("object length is not an integer", table.insert, t, 1)
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -150,7 +150,7 @@ test("[test-suite] sort: testing unpack", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -166,7 +166,7 @@ test("[test-suite] sort: testing unpack", function (t) {
test("[test-suite] sort: testing pack", function (t) {
let luaCode = `
a = table.pack()
- assert(a[1] == nil and a.n == 0)
+ assert(a[1] == nil and a.n == 0)
a = table.pack(table)
assert(a[1] == table and a.n == 1)
@@ -174,7 +174,7 @@ test("[test-suite] sort: testing pack", function (t) {
a = table.pack(nil, nil, nil, nil)
assert(a[1] == nil and a.n == 4)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -183,7 +183,7 @@ test("[test-suite] sort: testing pack", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -203,8 +203,8 @@ test("[test-suite] sort: testing move", function (t) {
checkerror("table expected", table.move, 1, 2, 3, 4)
local function eqT (a, b)
- for k, v in pairs(a) do assert(b[k] == v) end
- for k, v in pairs(b) do assert(a[k] == v) end
+ for k, v in pairs(a) do assert(b[k] == v) end
+ for k, v in pairs(b) do assert(a[k] == v) end
end
local a = table.move({10,20,30}, 1, 3, 2) -- move forward
@@ -269,7 +269,7 @@ test("[test-suite] sort: testing move", function (t) {
assert(not stat and msg == b)
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -278,7 +278,7 @@ test("[test-suite] sort: testing move", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -320,7 +320,7 @@ test("[test-suite] sort: testing long move", function (t) {
checkerror("wrap around", table.move, {}, 1, 2, maxI)
checkerror("wrap around", table.move, {}, minI, -2, 2)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -329,7 +329,7 @@ test("[test-suite] sort: testing long move", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -350,7 +350,7 @@ test("[test-suite] sort: testing sort, strange lengths", function (t) {
a = setmetatable({}, {__len = function () return maxI end})
checkerror("too big", table.sort, a)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -359,7 +359,7 @@ test("[test-suite] sort: testing sort, strange lengths", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -383,7 +383,7 @@ test("[test-suite] sort: test checks for invalid order functions", function (t)
check{1,2,3,4,5}
check{1,2,3,4,5,6}
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -392,7 +392,7 @@ test("[test-suite] sort: test checks for invalid order functions", function (t)
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -420,7 +420,7 @@ test("[test-suite] sort: sort alpha", function (t) {
table.sort(a)
check(a)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -429,7 +429,7 @@ test("[test-suite] sort: sort alpha", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -477,7 +477,7 @@ test("[test-suite] sort: sort perm", function (t) {
perm{1,2,3,4,5,6}
perm{2,2,3,3,5,6}
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -486,7 +486,7 @@ test("[test-suite] sort: sort perm", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -527,7 +527,7 @@ test("[test-suite] sort: Invert-sorting", function (t) {
for i,v in pairs(a) do assert(v == false) end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -536,7 +536,7 @@ test("[test-suite] sort: Invert-sorting", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -576,7 +576,7 @@ test("[test-suite] sort: sorting", function (t) {
check(a, tt.__lt)
check(a)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -585,7 +585,7 @@ test("[test-suite] sort: sorting", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
diff --git a/tests/test-suite/strings.js b/tests/test-suite/strings.js
index 0efedcb..cbffe5c 100644
--- a/tests/test-suite/strings.js
+++ b/tests/test-suite/strings.js
@@ -5,7 +5,7 @@ const test = require('tape');
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
const lualib = require('../../src/lualib.js');
-
+const {to_luastring} = require("../../src/fengaricore.js");
const checkerror = `
local maxi, mini = math.maxinteger, math.mininteger
@@ -45,7 +45,7 @@ test('[test-suite] strings: string comparisons', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkerror + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
}, "Lua program loaded without error");
@@ -87,7 +87,7 @@ test('[test-suite] strings: string.sub', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkerror + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
}, "Lua program loaded without error");
@@ -125,7 +125,7 @@ test('[test-suite] strings: string.find', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkerror + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
}, "Lua program loaded without error");
@@ -157,7 +157,7 @@ test('[test-suite] strings: string.len and #', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkerror + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
}, "Lua program loaded without error");
@@ -214,7 +214,7 @@ test('[test-suite] strings: string.byte/string.char', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkerror + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
}, "Lua program loaded without error");
@@ -251,7 +251,7 @@ test('[test-suite] strings: repetitions with separator', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkerror + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
}, "Lua program loaded without error");
@@ -303,7 +303,7 @@ test('[test-suite] strings: tostring', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkerror + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
}, "Lua program loaded without error");
@@ -350,7 +350,7 @@ test('[test-suite] strings: string.format', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkerror + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
}, "Lua program loaded without error");
@@ -391,7 +391,7 @@ test('[test-suite] strings: %q', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkerror + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
}, "Lua program loaded without error");
@@ -418,7 +418,7 @@ test('[test-suite] strings: embedded zeros error', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkerror + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
}, "Lua program loaded without error");
@@ -461,7 +461,7 @@ test('[test-suite] strings: format x tostring', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkerror + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
}, "Lua program loaded without error");
@@ -498,7 +498,7 @@ test('[test-suite] strings: longest number that can be formatted', function (t)
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkerror + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
}, "Lua program loaded without error");
@@ -547,7 +547,7 @@ test('[test-suite] strings: large numbers for format', function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkerror + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
}, "Lua program loaded without error");
@@ -604,7 +604,7 @@ test("[test-suite] strings: 'format %a %A'", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkerror + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
}, "Lua program loaded without error");
@@ -644,7 +644,7 @@ test("[test-suite] strings: errors in format", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkerror + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
}, "Lua program loaded without error");
@@ -695,7 +695,7 @@ test("[test-suite] strings: table.concat", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkerror + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
}, "Lua program loaded without error");
@@ -751,7 +751,7 @@ test.skip("[test-suite] strings: locale", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkerror + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
}, "Lua program loaded without error");
@@ -782,7 +782,7 @@ test("[test-suite] strings: bug in Lua 5.3.2: 'gmatch' iterator does not work ac
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkerror + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
}, "Lua program loaded without error");
diff --git a/tests/test-suite/tpack.js b/tests/test-suite/tpack.js
index ebce4e4..745c151 100644
--- a/tests/test-suite/tpack.js
+++ b/tests/test-suite/tpack.js
@@ -5,7 +5,7 @@ const test = require('tape');
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
const lualib = require('../../src/lualib.js');
-
+const {to_luastring} = require("../../src/fengaricore.js");
const prefix = `
local pack = string.pack
@@ -55,7 +55,7 @@ test("[test-suite] tpack: maximum size for integers", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -91,7 +91,7 @@ test("[test-suite] tpack: minimum behavior for integer formats", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -130,7 +130,7 @@ test("[test-suite] tpack: minimum behavior for integer formats", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -175,7 +175,7 @@ test("[test-suite] tpack: minimum behavior for integer formats", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -209,7 +209,7 @@ test("[test-suite] tpack: minimum behavior for integer formats", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -242,7 +242,7 @@ test("[test-suite] tpack: sign extension", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -273,7 +273,7 @@ test("[test-suite] tpack: mixed endianness", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -308,7 +308,7 @@ test("[test-suite] tpack: testing invalid formats", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -343,7 +343,7 @@ test("[test-suite] tpack: overflow in option size (error will be in digit after
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -384,7 +384,7 @@ test("[test-suite] tpack: overflow in packing", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -418,7 +418,7 @@ test("[test-suite] tpack: Lua integer size", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -458,7 +458,7 @@ test("[test-suite] tpack: testing pack/unpack of floating-point numbers", functi
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -524,7 +524,7 @@ test("[test-suite] tpack: testing pack/unpack of strings", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -544,7 +544,7 @@ test("[test-suite] tpack: testing multiple types and sequence", function (t) {
assert(#x == packsize("<b h b f d f n i"))
local a, b, c, d, e, f, g, h = unpack("<b h b f d f n i", x)
assert(a == 1 and b == 2 and c == 3 and d == 4 and e == 5 and f == 6 and
- g == 7 and h == 8)
+ g == 7 and h == 8)
end
`, L;
@@ -556,7 +556,7 @@ test("[test-suite] tpack: testing multiple types and sequence", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -577,7 +577,7 @@ test("[test-suite] tpack: testing alignment", function (t) {
assert(#x == packsize(">!8 b Xh i4 i8 c1 Xi8"))
assert(x == "\\xf4" .. "\\0\\0\\0" ..
"\\0\\0\\0\\100" ..
- "\\0\\0\\0\\0\\0\\0\\0\\xC8" ..
+ "\\0\\0\\0\\0\\0\\0\\0\\xC8" ..
"\\xEC" .. "\\0\\0\\0\\0\\0\\0\\0")
local a, b, c, d, pos = unpack(">!8 c1 Xh i4 i8 b Xi8 XI XH", x)
assert(a == "\\xF4" and b == 100 and c == 200 and d == -20 and (pos - 1) == #x)
@@ -622,7 +622,7 @@ test("[test-suite] tpack: testing alignment", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
@@ -665,7 +665,7 @@ test("[test-suite] tpack: testing initial position", function (t) {
checkerror("out of string", unpack, "c0", x, 0)
checkerror("out of string", unpack, "c0", x, #x + 2)
checkerror("out of string", unpack, "c0", x, -(#x + 1))
-
+
end
`, L;
@@ -677,7 +677,7 @@ test("[test-suite] tpack: testing initial position", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
}, "Lua program loaded without error");
diff --git a/tests/test-suite/utf8.js b/tests/test-suite/utf8.js
index 11f699d..173dffd 100644
--- a/tests/test-suite/utf8.js
+++ b/tests/test-suite/utf8.js
@@ -5,7 +5,7 @@ const test = require('tape');
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
const lualib = require('../../src/lualib.js');
-
+const {to_luastring} = require("../../src/fengaricore.js");
const prefix = `
local function checkerror (msg, f, ...)
@@ -30,7 +30,7 @@ const prefix = `
end
-- 't' is the list of codepoints of 's'
local function check (s, t)
- local l = utf8.len(s)
+ local l = utf8.len(s)
assert(#t == l and len(s) == l)
assert(utf8.char(table.unpack(t)) == s)
@@ -49,7 +49,7 @@ const prefix = `
assert(utf8.offset(s, -1, pi1) == pi)
assert(utf8.offset(s, i - l - 1) == pi)
assert(pi1 - pi == #utf8.char(utf8.codepoint(s, pi)))
- for j = pi, pi1 - 1 do
+ for j = pi, pi1 - 1 do
assert(utf8.offset(s, 0, j) == pi)
end
for j = pi + 1, pi1 - 1 do
@@ -73,7 +73,7 @@ const prefix = `
i = 0
for p, c in utf8.codes(s) do
i = i + 1
- assert(c == t[i] and p == utf8.offset(s, i))
+ assert(c == t[i] and p == utf8.offset(s, i))
end
assert(i == #t)
@@ -97,33 +97,28 @@ const prefix = `
`;
test("[test-suite] utf8: offset", function (t) {
- let luaCode = `
+ let luaCode = prefix + `
assert(utf8.offset("alo", 5) == nil)
assert(utf8.offset("alo", -4) == nil)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
-
L = lauxlib.luaL_newstate();
-
lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
-
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
-
}, "Lua program ran without error");
});
test("[test-suite] utf8: error indication in utf8.len", function (t) {
- let luaCode = `
+ let luaCode = prefix + `
do
local function check (s, p)
local a, b = utf8.len(s)
@@ -135,29 +130,24 @@ test("[test-suite] utf8: error indication in utf8.len", function (t) {
check("\\xF4\\x9F\\xBF\\xBF", 1)
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
-
L = lauxlib.luaL_newstate();
-
lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
-
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
-
}, "Lua program ran without error");
});
test("[test-suite] utf8: error in initial position for offset", function (t) {
- let luaCode = `
+ let luaCode = prefix + `
checkerror("position out of range", utf8.offset, "abc", 1, 5)
checkerror("position out of range", utf8.offset, "abc", 1, -4)
checkerror("position out of range", utf8.offset, "", 1, 2)
@@ -166,29 +156,24 @@ test("[test-suite] utf8: error in initial position for offset", function (t) {
checkerror("continuation byte", utf8.offset, "𦧺", 1, 2)
checkerror("continuation byte", utf8.offset, "\\x80", 1)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
-
L = lauxlib.luaL_newstate();
-
lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
-
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
-
}, "Lua program ran without error");
});
test("[test-suite] utf8: codepoints", function (t) {
- let luaCode = `
+ let luaCode = prefix + `
local s = "hello World"
local t = {string.byte(s, 1, -1)}
for i = 1, utf8.len(s) do assert(t[i] == string.byte(s, i)) end
@@ -215,135 +200,110 @@ test("[test-suite] utf8: codepoints", function (t) {
checkerror("value out of range", utf8.char, 0x10FFFF + 1)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
-
L = lauxlib.luaL_newstate();
-
lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
-
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
-
}, "Lua program ran without error");
});
test("[test-suite] utf8: UTF-8 representation for 0x11ffff (value out of valid range)", function (t) {
- let luaCode = `
+ let luaCode = prefix + `
invalid("\\xF4\\x9F\\xBF\\xBF")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
-
L = lauxlib.luaL_newstate();
-
lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
-
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
-
}, "Lua program ran without error");
});
test("[test-suite] utf8: overlong sequences", function (t) {
- let luaCode = `
+ let luaCode = prefix + `
invalid("\\xC0\\x80") -- zero
invalid("\\xC1\\xBF") -- 0x7F (should be coded in 1 byte)
invalid("\\xE0\\x9F\\xBF") -- 0x7FF (should be coded in 2 bytes)
invalid("\\xF0\\x8F\\xBF\\xBF") -- 0xFFFF (should be coded in 3 bytes)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
-
L = lauxlib.luaL_newstate();
-
lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
-
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
-
}, "Lua program ran without error");
});
test("[test-suite] utf8: invalid bytes", function (t) {
- let luaCode = `
+ let luaCode = prefix + `
invalid("\\x80") -- continuation byte
invalid("\\xBF") -- continuation byte
invalid("\\xFE") -- invalid byte
invalid("\\xFF") -- invalid byte
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
-
L = lauxlib.luaL_newstate();
-
lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
-
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
-
}, "Lua program ran without error");
});
test("[test-suite] utf8: empty strings", function (t) {
- let luaCode = `
+ let luaCode = prefix + `
check("", {})
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
-
L = lauxlib.luaL_newstate();
-
lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
-
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
-
}, "Lua program ran without error");
});
test("[test-suite] utf8: minimum and maximum values for each sequence size", function (t) {
- let luaCode = `
+ let luaCode = prefix + `
s = "\\0 \\x7F\\z
\\xC2\\x80 \\xDF\\xBF\\z
\\xE0\\xA0\\x80 \\xEF\\xBF\\xBF\\z
@@ -377,18 +337,13 @@ test("[test-suite] utf8: minimum and maximum values for each sequence size", fun
t.plan(2);
t.doesNotThrow(function () {
-
L = lauxlib.luaL_newstate();
-
lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, lua.to_luastring(prefix + luaCode));
-
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
}, "Lua program loaded without error");
t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
-
}, "Lua program ran without error");
});
diff --git a/tests/test-suite/vararg.js b/tests/test-suite/vararg.js
index dc90248..1cc5ace 100644
--- a/tests/test-suite/vararg.js
+++ b/tests/test-suite/vararg.js
@@ -5,7 +5,7 @@ const test = require('tape');
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
const lualib = require('../../src/lualib.js');
-
+const {to_luastring} = require("../../src/fengaricore.js");
test("[test-suite] vararg: testing vararg", function (t) {
let luaCode = `
@@ -73,7 +73,7 @@ test("[test-suite] vararg: testing vararg", function (t) {
while i <= lim do a[i] = i; i=i+1 end
assert(call(math.max, a) == lim)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -82,7 +82,7 @@ test("[test-suite] vararg: testing vararg", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -118,7 +118,7 @@ test("[test-suite] vararg: new-style varargs", function (t) {
a,b,c,d,e = f(4)
assert(a==nil and b==nil and c==nil and d==nil and e==nil)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -127,7 +127,7 @@ test("[test-suite] vararg: new-style varargs", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -168,7 +168,7 @@ test("[test-suite] vararg: varargs for main chunks", function (t) {
pcall(select, 10000)
pcall(select, -10000)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -177,7 +177,7 @@ test("[test-suite] vararg: varargs for main chunks", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
@@ -204,7 +204,7 @@ test("[test-suite] vararg: bug in 5.2.2", function (t) {
-- assertion fail here
f()
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -213,7 +213,7 @@ test("[test-suite] vararg: bug in 5.2.2", function (t) {
lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode));
}, "Lua program loaded without error");
diff --git a/tests/tests.js b/tests/tests.js
index 1ad9900..778cbef 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -2,6 +2,7 @@
const lua = require("../src/lua.js");
const lauxlib = require("../src/lauxlib.js");
+const {to_luastring} = require("../src/fengaricore.js");
const toByteCode = function(luaCode) {
let L = getState(luaCode);
@@ -19,7 +20,7 @@ const getState = function(luaCode) {
if (!L)
throw Error("unable to create lua_State");
- if (lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode)) !== lua.LUA_OK)
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) !== lua.LUA_OK)
throw Error(lua.lua_tojsstring(L, -1));
return L;