summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/lapi.js90
-rw-r--r--tests/lbaselib.js68
-rw-r--r--tests/lcorolib.js16
-rw-r--r--tests/ldebug.js30
-rw-r--r--tests/lexparse.js127
-rw-r--r--tests/lmathlib.js32
-rw-r--r--tests/load.js12
-rw-r--r--tests/lstrlib.js71
-rw-r--r--tests/ltablib.js20
-rw-r--r--tests/ltm.js55
-rw-r--r--tests/lutf8lib.js6
-rw-r--r--tests/lvm.js20
12 files changed, 275 insertions, 272 deletions
diff --git a/tests/lapi.js b/tests/lapi.js
index c422ada..c6e9c53 100644
--- a/tests/lapi.js
+++ b/tests/lapi.js
@@ -28,9 +28,9 @@ test('luaL_newstate, lua_pushnil, luaL_typename', function (t) {
}, "JS Lua program ran without error");
- t.strictEqual(
+ t.deepEqual(
lauxlib.luaL_typename(L, -1),
- "nil",
+ "nil".split('').map(e => e.charCodeAt(0)),
"Correct element(s) on the stack"
);
});
@@ -49,9 +49,9 @@ test('lua_pushnumber', function (t) {
}, "JS Lua program ran without error");
- t.strictEqual(
+ t.deepEqual(
lauxlib.luaL_typename(L, -1),
- "number",
+ "number".split('').map(e => e.charCodeAt(0)),
"Correct element(s) on the stack"
);
@@ -76,9 +76,9 @@ test('lua_pushinteger', function (t) {
}, "JS Lua program ran without error");
- t.strictEqual(
+ t.deepEqual(
lauxlib.luaL_typename(L, -1),
- "number",
+ "number".split('').map(e => e.charCodeAt(0)),
"Correct element(s) on the stack"
);
@@ -90,7 +90,7 @@ test('lua_pushinteger', function (t) {
});
-test('lua_pushstring', function (t) {
+test('lua_pushliteral', function (t) {
let L;
t.plan(3);
@@ -99,18 +99,18 @@ test('lua_pushstring', function (t) {
L = lauxlib.luaL_newstate();
- lapi.lua_pushstring(L, "hello");
+ lapi.lua_pushliteral(L, "hello");
}, "JS Lua program ran without error");
- t.strictEqual(
+ t.deepEqual(
lauxlib.luaL_typename(L, -1),
- "string",
+ "string".split('').map(e => e.charCodeAt(0)),
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello",
"top is correct"
);
@@ -130,9 +130,9 @@ test('lua_pushboolean', function (t) {
}, "JS Lua program ran without error");
- t.strictEqual(
+ t.deepEqual(
lauxlib.luaL_typename(L, -1),
- "boolean",
+ "boolean".split('').map(e => e.charCodeAt(0)),
"Correct element(s) on the stack"
);
@@ -153,32 +153,32 @@ test('lua_pushvalue', function (t) {
L = lauxlib.luaL_newstate();
- lapi.lua_pushstring(L, "hello");
+ lapi.lua_pushliteral(L, "hello");
lapi.lua_pushvalue(L, -1);
}, "JS Lua program ran without error");
- t.strictEqual(
+ t.deepEqual(
lauxlib.luaL_typename(L, -1),
- "string",
+ "string".split('').map(e => e.charCodeAt(0)),
"Correct element(s) on the stack"
);
- t.strictEqual(
+ t.deepEqual(
lauxlib.luaL_typename(L, -2),
- "string",
+ "string".split('').map(e => e.charCodeAt(0)),
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -2),
+ lapi.lua_tojsstring(L, -2),
"hello",
"Correct element(s) on the stack"
);
@@ -198,14 +198,14 @@ test('lua_pushjsclosure', function (t) {
L = lauxlib.luaL_newstate();
- lapi.lua_pushstring(L, "a value associated to the C closure");
+ lapi.lua_pushliteral(L, "a value associated to the C closure");
lapi.lua_pushjsclosure(L, fn, 1);
}, "JS Lua program ran without error");
- t.strictEqual(
+ t.deepEqual(
lauxlib.luaL_typename(L, -1),
- "function",
+ "function".split('').map(e => e.charCodeAt(0)),
"Correct element(s) on the stack"
);
});
@@ -228,9 +228,9 @@ test('lua_pushjsfunction', function (t) {
}, "JS Lua program ran without error");
- t.strictEqual(
+ t.deepEqual(
lauxlib.luaL_typename(L, -1),
- "function",
+ "function".split('').map(e => e.charCodeAt(0)),
"Correct element(s) on the stack"
);
});
@@ -244,7 +244,7 @@ test('lua_call (calling a light JS function)', function (t) {
t.doesNotThrow(function () {
let fn = function(L) {
- lapi.lua_pushstring(L, "hello");
+ lapi.lua_pushliteral(L, "hello");
return 1;
};
@@ -257,7 +257,7 @@ test('lua_call (calling a light JS function)', function (t) {
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello",
"top is correct"
);
@@ -278,7 +278,7 @@ test('lua_call (calling a JS closure)', function (t) {
L = lauxlib.luaL_newstate();
- lapi.lua_pushstring(L, "upvalue hello !");
+ lapi.lua_pushliteral(L, "upvalue hello !");
lapi.lua_pushjsclosure(L, fn, 1);
lapi.lua_call(L, 0, 1);
@@ -286,7 +286,7 @@ test('lua_call (calling a JS closure)', function (t) {
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"upvalue hello !",
"top is correct"
);
@@ -301,7 +301,7 @@ test('lua_pcall (calling a light JS function)', function (t) {
t.doesNotThrow(function () {
let fn = function(L) {
- lapi.lua_pushstring(L, "hello");
+ lapi.lua_pushliteral(L, "hello");
return 1;
};
@@ -314,7 +314,7 @@ test('lua_pcall (calling a light JS function)', function (t) {
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello",
"top is correct"
);
@@ -353,15 +353,15 @@ test('lua_pop', function (t) {
L = lauxlib.luaL_newstate();
- lapi.lua_pushstring(L, "hello");
- lapi.lua_pushstring(L, "world");
+ lapi.lua_pushliteral(L, "hello");
+ lapi.lua_pushliteral(L, "world");
lapi.lua_pop(L, 1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello",
"Correct element(s) on the stack"
);
@@ -382,14 +382,14 @@ test('lua_load and lua_call it', function (t) {
L = lauxlib.luaL_newstate();
- lapi.lua_load(L, null, bc, "test-lua_load", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-lua_load"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, 1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"JS > Lua > JS \o/",
"Correct element(s) on the stack"
);
@@ -409,17 +409,17 @@ test('lua script reads js upvalues', function (t) {
L = lauxlib.luaL_newstate();
- lapi.lua_load(L, null, bc, "test-lua_load", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-lua_load"), lua.to_luastring("binary"));
- lapi.lua_pushstring(L, "hello");
- lapi.lua_setglobal(L, "js");
+ lapi.lua_pushliteral(L, "hello");
+ lapi.lua_setglobal(L, lua.to_luastring("js"));
lapi.lua_call(L, 0, 1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello world",
"Correct element(s) on the stack"
);
@@ -474,19 +474,19 @@ test('lua_settable, lua_gettable', function (t) {
lapi.lua_newtable(L);
- lapi.lua_pushstring(L, "key");
- lapi.lua_pushstring(L, "value");
+ lapi.lua_pushliteral(L, "key");
+ lapi.lua_pushliteral(L, "value");
lapi.lua_settable(L, -3);
- lapi.lua_pushstring(L, "key");
+ lapi.lua_pushliteral(L, "key");
lapi.lua_gettable(L, -2);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"value",
"Correct element(s) on the stack"
);
-}); \ No newline at end of file
+});
diff --git a/tests/lbaselib.js b/tests/lbaselib.js
index be741dc..dd91449 100644
--- a/tests/lbaselib.js
+++ b/tests/lbaselib.js
@@ -31,7 +31,7 @@ test('print', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-print", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-print"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -65,14 +65,14 @@ test('setmetatable, getmetatable', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-setmetatable-getmetatable", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-setmetatable-getmetatable"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -2),
+ lapi.lua_tojsstring(L, -2),
"hello",
"Correct element(s) on the stack"
);
@@ -110,7 +110,7 @@ test('rawequal', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-rawequal", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-rawequal"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -156,32 +156,32 @@ test('rawset, rawget', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-rawequal", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-rawequal"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -4),
+ lapi.lua_tojsstring(L, -4),
"hello",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -3),
+ lapi.lua_tojsstring(L, -3),
"hello",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -2),
+ lapi.lua_tojsstring(L, -2),
"bye",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"bye",
"Correct element(s) on the stack"
);
@@ -203,38 +203,38 @@ test('type', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-type", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-type"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -5),
+ lapi.lua_tojsstring(L, -5),
"number",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -4),
+ lapi.lua_tojsstring(L, -4),
"boolean",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -3),
+ lapi.lua_tojsstring(L, -3),
"string",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -2),
+ lapi.lua_tojsstring(L, -2),
"table",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"nil",
"Correct element(s) on the stack"
);
@@ -256,7 +256,7 @@ test('error', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-error", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-error"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -279,14 +279,14 @@ test('error, protected', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-error", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-error"), lua.to_luastring("binary"));
lapi.lua_pcall(L, 0, -1, 0);
}, "JS Lua program ran without error");
t.ok(
- lapi.lua_tostring(L, -1).endsWith("you fucked up"),
+ lapi.lua_tojsstring(L, -1).endsWith("you fucked up"),
"Error is on the stack"
);
});
@@ -311,14 +311,14 @@ test('pcall', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-pcall", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-pcall"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.ok(
- lapi.lua_tostring(L, -1).endsWith("you fucked up"),
+ lapi.lua_tojsstring(L, -1).endsWith("you fucked up"),
"Error is on the stack"
);
});
@@ -347,21 +347,21 @@ test('xpcall', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-pcall", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-pcall"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
- console.log(lapi.lua_tostring(L, -1));
+ console.log(lapi.lua_tojsstring(L, -1));
t.ok(
- lapi.lua_tostring(L, -1).startsWith("Something's wrong:"),
+ lapi.lua_tojsstring(L, -1).startsWith("Something's wrong:"),
"msgh was called and modified the error"
);
t.ok(
- lapi.lua_tostring(L, -1).endsWith("you fucked up"),
+ lapi.lua_tojsstring(L, -1).endsWith("you fucked up"),
"msgh was called and modified the error"
);
});
@@ -389,7 +389,7 @@ test('ipairs', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-ipairs", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-ipairs"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -418,7 +418,7 @@ test('select', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-select", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-select"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -459,7 +459,7 @@ test('tonumber', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-tonumber", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-tonumber"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -506,14 +506,14 @@ test('assert', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-assert", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-assert"), lua.to_luastring("binary"));
lapi.lua_pcall(L, 0, -1, 0);
}, "JS Lua program ran without error");
t.ok(
- lapi.lua_tostring(L, -1).endsWith("this doesn't makes sense"),
+ lapi.lua_tojsstring(L, -1).endsWith("this doesn't makes sense"),
"Error is on the stack"
);
});
@@ -534,7 +534,7 @@ test('rawlen', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-rawlen", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-rawlen"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -581,7 +581,7 @@ test('next', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-next", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-next"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -622,7 +622,7 @@ test('pairs', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-pairs", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-pairs"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -672,7 +672,7 @@ test('pairs with __pairs', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-pairs", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-pairs"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -683,4 +683,4 @@ test('pairs with __pairs', function (t) {
26,
"Correct element(s) on the stack"
);
-}); \ No newline at end of file
+});
diff --git a/tests/lcorolib.js b/tests/lcorolib.js
index 9c1d9b1..f709fa5 100644
--- a/tests/lcorolib.js
+++ b/tests/lcorolib.js
@@ -40,7 +40,7 @@ test('coroutine.create, coroutine.yield, coroutine.resume', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-coroutine", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-coroutine"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -83,20 +83,20 @@ test('coroutine.status', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-coroutine.status", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-coroutine.status"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -2),
+ lapi.lua_tojsstring(L, -2),
"suspended",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"dead",
"Correct element(s) on the stack"
);
@@ -124,7 +124,7 @@ test('coroutine.isyieldable', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-coroutine.isyieldable", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-coroutine.isyieldable"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -165,7 +165,7 @@ test('coroutine.running', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-coroutine.running", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-coroutine.running"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -206,7 +206,7 @@ test('coroutine.wrap', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-coroutine.wrap", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-coroutine.wrap"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -217,4 +217,4 @@ test('coroutine.wrap', function (t) {
625,
"Correct element(s) on the stack"
);
-}); \ No newline at end of file
+});
diff --git a/tests/ldebug.js b/tests/ldebug.js
index 0261305..e24b584 100644
--- a/tests/ldebug.js
+++ b/tests/ldebug.js
@@ -30,7 +30,7 @@ test('luaG_typeerror', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-typeerror", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-typeerror"), lua.to_luastring("binary"));
lapi.lua_pcall(L, 0, -1, 0);
@@ -38,7 +38,7 @@ test('luaG_typeerror', function (t) {
t.ok(
- lapi.lua_tostring(L, -1).endsWith("attempt to get length of a boolean value (local 'a')"),
+ lapi.lua_tojsstring(L, -1).endsWith("attempt to get length of a boolean value (local 'a')"),
"Correct error was thrown"
);
});
@@ -60,14 +60,14 @@ test('luaG_typeerror', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-typeerror", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-typeerror"), lua.to_luastring("binary"));
lapi.lua_pcall(L, 0, -1, 0);
}, "JS Lua program ran without error");
t.ok(
- lapi.lua_tostring(L, -1).endsWith("attempt to index a boolean value (local 'a')"),
+ lapi.lua_tojsstring(L, -1).endsWith("attempt to index a boolean value (local 'a')"),
"Correct error was thrown"
);
});
@@ -89,14 +89,14 @@ test('luaG_typeerror', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-typeerror", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-typeerror"), lua.to_luastring("binary"));
lapi.lua_pcall(L, 0, -1, 0);
}, "JS Lua program ran without error");
t.ok(
- lapi.lua_tostring(L, -1).endsWith("attempt to index a boolean value (local 'a')"),
+ lapi.lua_tojsstring(L, -1).endsWith("attempt to index a boolean value (local 'a')"),
"Correct error was thrown"
);
});
@@ -118,14 +118,14 @@ test('luaG_typeerror', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-typeerror", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-typeerror"), lua.to_luastring("binary"));
lapi.lua_pcall(L, 0, -1, 0);
}, "JS Lua program ran without error");
t.ok(
- lapi.lua_tostring(L, -1).endsWith("attempt to index a boolean value (local 'a')"),
+ lapi.lua_tojsstring(L, -1).endsWith("attempt to index a boolean value (local 'a')"),
"Correct error was thrown"
);
});
@@ -146,14 +146,14 @@ test('luaG_concaterror', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-typeerror", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-typeerror"), lua.to_luastring("binary"));
lapi.lua_pcall(L, 0, -1, 0);
}, "JS Lua program ran without error");
t.ok(
- lapi.lua_tostring(L, -1).endsWith("attempt to concatenate a table value"),
+ lapi.lua_tojsstring(L, -1).endsWith("attempt to concatenate a table value"),
"Correct error was thrown"
);
});
@@ -174,14 +174,14 @@ test('luaG_opinterror', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-typeerror", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-typeerror"), lua.to_luastring("binary"));
lapi.lua_pcall(L, 0, -1, 0);
}, "JS Lua program ran without error");
t.ok(
- lapi.lua_tostring(L, -1).endsWith("attempt to perform arithmetic on a string value"),
+ lapi.lua_tojsstring(L, -1).endsWith("attempt to perform arithmetic on a string value"),
"Correct error was thrown"
);
});
@@ -202,14 +202,14 @@ test('luaG_tointerror', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-typeerror", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-typeerror"), lua.to_luastring("binary"));
lapi.lua_pcall(L, 0, -1, 0);
}, "JS Lua program ran without error");
t.ok(
- lapi.lua_tostring(L, -1).endsWith("number has no integer representation"),
+ lapi.lua_tojsstring(L, -1).endsWith("number has no integer representation"),
"Correct error was thrown"
);
-}); \ No newline at end of file
+});
diff --git a/tests/lexparse.js b/tests/lexparse.js
index 704f875..edffe53 100644
--- a/tests/lexparse.js
+++ b/tests/lexparse.js
@@ -6,6 +6,7 @@ const beautify = require('js-beautify').js_beautify;
const tests = require("./tests.js");
const toByteCode = tests.toByteCode;
+const lua = require("../src/lua.js");
const lapi = require("../src/lapi.js");
const lauxlib = require("../src/lauxlib.js");
const linit = require('../src/linit.js');
@@ -28,12 +29,12 @@ test('LOADK, RETURN', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -44,7 +45,7 @@ test('LOADK, RETURN', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello world",
"Correct element(s) on the stack"
);
@@ -68,12 +69,12 @@ test('MOVE', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -84,7 +85,7 @@ test('MOVE', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello world",
"Correct element(s) on the stack"
);
@@ -108,12 +109,12 @@ test('Binary op', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -148,12 +149,12 @@ test('Unary op, LOADBOOL', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -186,12 +187,12 @@ test('NEWTABLE', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -228,12 +229,12 @@ test('CALL', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -274,12 +275,12 @@ test('Multiple return', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -315,12 +316,12 @@ test('TAILCALL', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -356,12 +357,12 @@ test('VARARG', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -395,12 +396,12 @@ test('LE, JMP', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -434,12 +435,12 @@ test('LT', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -473,12 +474,12 @@ test('EQ', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -513,12 +514,12 @@ test('TESTSET (and)', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -529,7 +530,7 @@ test('TESTSET (and)', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello",
"Program output is correct"
);
@@ -553,12 +554,12 @@ test('TESTSET (or)', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -569,7 +570,7 @@ test('TESTSET (or)', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello",
"Program output is correct"
);
@@ -597,12 +598,12 @@ test('TEST (false)', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -613,7 +614,7 @@ test('TEST (false)', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"goodbye",
"Program output is correct"
);
@@ -640,12 +641,12 @@ test('FORPREP, FORLOOP (int)', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -683,12 +684,12 @@ test('FORPREP, FORLOOP (float)', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -725,12 +726,12 @@ test('SETTABLE, GETTABLE', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -776,12 +777,12 @@ test('SETUPVAL, GETUPVAL', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -792,7 +793,7 @@ test('SETUPVAL, GETUPVAL', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"world",
"Program output is correct"
);
@@ -818,12 +819,12 @@ test('SETTABUP, GETTABUP', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -868,12 +869,12 @@ test('SELF', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -884,7 +885,7 @@ test('SELF', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello",
"Program output is correct"
);
@@ -907,12 +908,12 @@ test('SETLIST', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -950,12 +951,12 @@ test('Variable SETLIST', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -988,12 +989,12 @@ test('Long SETLIST', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -1043,12 +1044,12 @@ test('TFORCALL, TFORLOOP', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -1084,12 +1085,12 @@ test('LEN', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -1133,12 +1134,12 @@ test('CONCAT', function (t) {
linit.luaL_openlibs(L);
let reader = function(L, data) {
- let code = luaCode;
+ let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code;
};
- lapi.lua_load(L, reader, luaCode, "test", "text");
+ lapi.lua_load(L, reader, luaCode, lua.to_luastring("test"), lua.to_luastring("text"));
}, "Lua program loaded without error");
@@ -1149,8 +1150,8 @@ test('CONCAT', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello 2 you",
"Program output is correct"
);
-}); \ No newline at end of file
+});
diff --git a/tests/lmathlib.js b/tests/lmathlib.js
index ae0c40b..6105af4 100644
--- a/tests/lmathlib.js
+++ b/tests/lmathlib.js
@@ -33,7 +33,7 @@ test('math.abs, math.sin, math.cos, math.tan, math.asin, math.acos, math.atan',
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-math", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -98,7 +98,7 @@ test('math.ceil, math.floor', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-math", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -134,7 +134,7 @@ test('math.deg, math.rad', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-math", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -170,7 +170,7 @@ test('math.log', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-math", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -212,7 +212,7 @@ test('math.exp', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-math", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -242,7 +242,7 @@ test('math.min, math.max', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-math", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -278,7 +278,7 @@ test('math.random', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-math", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -312,7 +312,7 @@ test('math.sqrt', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-math", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -342,7 +342,7 @@ test('math.tointeger', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-math", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -372,26 +372,26 @@ test('math.type', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-math", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -3),
+ lapi.lua_tojsstring(L, -3),
"integer",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -2),
+ lapi.lua_tojsstring(L, -2),
"float",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
null,
"Correct element(s) on the stack"
);
@@ -414,7 +414,7 @@ test('math.ult', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-math", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -444,7 +444,7 @@ test('math.fmod', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-math", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -474,7 +474,7 @@ test('math.modf', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-math", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-math"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
diff --git a/tests/load.js b/tests/load.js
index 9b76ad3..9a53176 100644
--- a/tests/load.js
+++ b/tests/load.js
@@ -39,7 +39,7 @@ test('luaL_loadstring', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello world",
"Correct element(s) on the stack"
);
@@ -72,7 +72,7 @@ test('load', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"js running lua running lua",
"Correct element(s) on the stack"
);
@@ -107,7 +107,7 @@ test('luaL_loadbuffer', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello world",
"Correct element(s) on the stack"
);
@@ -140,7 +140,7 @@ test('loadfile', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello world",
"Correct element(s) on the stack"
);
@@ -173,7 +173,7 @@ test('loadfile (binary)', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello world",
"Correct element(s) on the stack"
);
@@ -205,7 +205,7 @@ test('dofile', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello world",
"Correct element(s) on the stack"
);
diff --git a/tests/lstrlib.js b/tests/lstrlib.js
index 12df173..2bde19d 100644
--- a/tests/lstrlib.js
+++ b/tests/lstrlib.js
@@ -6,6 +6,7 @@ const beautify = require('js-beautify').js_beautify;
const tests = require("./tests.js");
const toByteCode = tests.toByteCode;
+const lua = require("../src/lua.js");
const lapi = require("../src/lapi.js");
const lauxlib = require("../src/lauxlib.js");
const linit = require('../src/linit.js');
@@ -74,7 +75,7 @@ test('string.char', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello",
"Correct element(s) on the stack"
);
@@ -105,13 +106,13 @@ test('string.upper, string.lower', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -2),
+ lapi.lua_tojsstring(L, -2),
"HELLO",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello",
"Correct element(s) on the stack"
);
@@ -142,7 +143,7 @@ test('string.rep', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello, hello, hello",
"Correct element(s) on the stack"
);
@@ -173,7 +174,7 @@ test('string.reverse', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello",
"Correct element(s) on the stack"
);
@@ -247,7 +248,7 @@ test('string.format', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"%10 0000000023",
"Correct element(s) on the stack"
);
@@ -278,7 +279,7 @@ test('string.format', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"FFFFFFF",
"Correct element(s) on the stack"
);
@@ -309,7 +310,7 @@ test('string.format', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
'"a string with \\"quotes\\" and \\\n new line"',
"Correct element(s) on the stack"
);
@@ -350,67 +351,67 @@ test('string.sub', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -11),
+ lapi.lua_tojsstring(L, -11),
"234",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -10),
+ lapi.lua_tojsstring(L, -10),
"789",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -9),
+ lapi.lua_tojsstring(L, -9),
"",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -8),
+ lapi.lua_tojsstring(L, -8),
"7",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -7),
+ lapi.lua_tojsstring(L, -7),
"",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -6),
+ lapi.lua_tojsstring(L, -6),
"123456789",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -5),
+ lapi.lua_tojsstring(L, -5),
"123456789",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -4),
+ lapi.lua_tojsstring(L, -4),
"",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -3),
+ lapi.lua_tojsstring(L, -3),
"9",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -2),
+ lapi.lua_tojsstring(L, -2),
"6789",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"456",
"Correct element(s) on the stack"
);
@@ -448,14 +449,14 @@ test('string.dump', function (t) {
let dv = lapi.lua_todataview(L, -1);
- lapi.lua_load(L, null, dv, "test", "binary");
+ lapi.lua_load(L, null, dv, lua.to_luastring("test"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello1212.5",
"Correct element(s) on the stack"
);
@@ -562,13 +563,13 @@ test('string.match', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -2),
+ lapi.lua_tojsstring(L, -2),
"foo",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"123",
"Correct element(s) on the stack"
);
@@ -611,13 +612,13 @@ test('string.find', function (t) {
);
t.strictEqual(
- lapi.lua_tostring(L, -2),
+ lapi.lua_tojsstring(L, -2),
"foo",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"123",
"Correct element(s) on the stack"
);
@@ -655,25 +656,25 @@ test('string.gmatch', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -4),
+ lapi.lua_tojsstring(L, -4),
"hello",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -3),
+ lapi.lua_tojsstring(L, -3),
"world",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -2),
+ lapi.lua_tojsstring(L, -2),
"from",
"Correct element(s) on the stack"
);
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"Lua",
"Correct element(s) on the stack"
);
@@ -704,7 +705,7 @@ test('string.gsub', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -2),
+ lapi.lua_tojsstring(L, -2),
"hello hello world world",
"Correct element(s) on the stack"
);
@@ -741,7 +742,7 @@ test('string.gsub (number)', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -2),
+ lapi.lua_tojsstring(L, -2),
"hello hello world",
"Correct element(s) on the stack"
);
@@ -778,7 +779,7 @@ test('string.gsub (pattern)', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -2),
+ lapi.lua_tojsstring(L, -2),
"world hello Lua from",
"Correct element(s) on the stack"
);
@@ -817,7 +818,7 @@ test('string.gsub (function)', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -2),
+ lapi.lua_tojsstring(L, -2),
"4+5 = 9",
"Correct element(s) on the stack"
);
@@ -856,7 +857,7 @@ test('string.gsub (table)', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -2),
+ lapi.lua_tojsstring(L, -2),
"lua-5.3.tar.gz",
"Correct element(s) on the stack"
);
@@ -866,4 +867,4 @@ test('string.gsub (table)', function (t) {
2,
"Correct element(s) on the stack"
);
-}); \ No newline at end of file
+});
diff --git a/tests/ltablib.js b/tests/ltablib.js
index c8a1e73..81ffcbd 100644
--- a/tests/ltablib.js
+++ b/tests/ltablib.js
@@ -42,14 +42,14 @@ test('table.concat', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-table.concat", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-table.concat"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
}, "JS Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"3,4,5",
"Correct element(s) on the stack"
);
@@ -71,7 +71,7 @@ test('table.pack', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-table.pack", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-table.pack"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -102,7 +102,7 @@ test('table.unpack', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-table.unpack", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-table.unpack"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -146,7 +146,7 @@ test('table.insert', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-table.insert", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-table.insert"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -180,7 +180,7 @@ test('table.remove', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-table.remove", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-table.remove"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -213,7 +213,7 @@ test('table.move', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-table.move", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-table.move"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -246,7 +246,7 @@ test('table.sort (<)', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-table.sort", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-table.sort"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -279,7 +279,7 @@ test('table.sort with cmp function', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test-table.sort", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test-table.sort"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
@@ -290,4 +290,4 @@ test('table.sort with cmp function', function (t) {
[5, 4, 3, 2, 1],
"Correct element(s) on the stack"
);
-}); \ No newline at end of file
+});
diff --git a/tests/ltm.js b/tests/ltm.js
index 9eedc4c..501b062 100644
--- a/tests/ltm.js
+++ b/tests/ltm.js
@@ -3,6 +3,7 @@
const test = require('tape');
const beautify = require('js-beautify').js_beautify;
+const lua = require("../src/lua.js");
const VM = require("../src/lvm.js");
const lapi = require("../src/lapi.js");
const linit = require("../src/linit.js");
@@ -31,7 +32,7 @@ test('__index, __newindex: with actual table', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
lapi.lua_call(L, 0, -1);
}, "Program executed without errors");
@@ -65,7 +66,7 @@ test('__newindex: with non table', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.throws(function () {
@@ -100,7 +101,7 @@ test('__index function in metatable', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
@@ -109,7 +110,7 @@ test('__index function in metatable', function (t) {
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"__index",
"Program output is correct"
);
@@ -144,7 +145,7 @@ test('__newindex function in metatable', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -186,7 +187,7 @@ test('__index table in metatable', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -194,7 +195,7 @@ test('__index table in metatable', function (t) {
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello",
"Program output is correct"
);
@@ -231,7 +232,7 @@ test('__newindex table in metatable', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -239,7 +240,7 @@ test('__newindex table in metatable', function (t) {
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"world",
"Program output is correct"
);
@@ -287,7 +288,7 @@ test('__index table with own metatable', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -295,7 +296,7 @@ test('__index table with own metatable', function (t) {
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello",
"Program output is correct"
);
@@ -342,7 +343,7 @@ test('__newindex table with own metatable', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -350,7 +351,7 @@ test('__newindex table with own metatable', function (t) {
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello",
"Program output is correct"
);
@@ -445,7 +446,7 @@ test('binary __xxx functions in metatable', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -499,7 +500,7 @@ test('__eq', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -539,7 +540,7 @@ test('__lt', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -579,7 +580,7 @@ test('__le', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -619,7 +620,7 @@ test('__le that uses __lt', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -663,7 +664,7 @@ test('__unm, __bnot', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -671,13 +672,13 @@ test('__unm, __bnot', function (t) {
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"world",
"Program output is correct"
);
t.strictEqual(
- lapi.lua_tostring(L, -2),
+ lapi.lua_tojsstring(L, -2),
"hello",
"Program output is correct"
);
@@ -710,7 +711,7 @@ test('__len', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -718,7 +719,7 @@ test('__len', function (t) {
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello",
"Program output is correct"
);
@@ -751,7 +752,7 @@ test('__concat', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -759,7 +760,7 @@ test('__concat', function (t) {
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello",
"Program output is correct"
);
@@ -792,7 +793,7 @@ test('__call', function (t) {
linit.luaL_openlibs(L);
- lapi.lua_load(L, null, bc, "test", "binary");
+ lapi.lua_load(L, null, bc, lua.to_luastring("test"), lua.to_luastring("binary"));
}, "Bytecode parsed without errors");
t.doesNotThrow(function () {
@@ -804,4 +805,4 @@ test('__call', function (t) {
["hello", "world", "wow"],
"Program output is correct"
);
-}); \ No newline at end of file
+});
diff --git a/tests/lutf8lib.js b/tests/lutf8lib.js
index 38d8f8a..7832bae 100644
--- a/tests/lutf8lib.js
+++ b/tests/lutf8lib.js
@@ -107,7 +107,7 @@ test('utf8.char', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"( ͡° ͜ʖ ͡° )",
"Correct element(s) on the stack"
);
@@ -176,9 +176,9 @@ test('utf8.codes', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"[1,40] [2,32] [3,865] [5,176] [7,32] [8,860] [10,662] [12,32] [13,865] [15,176] [17,32] [18,41] ",
"Correct element(s) on the stack"
);
-}); \ No newline at end of file
+});
diff --git a/tests/lvm.js b/tests/lvm.js
index 69195d1..bda4c4f 100644
--- a/tests/lvm.js
+++ b/tests/lvm.js
@@ -26,7 +26,7 @@ test('LOADK, RETURN', function (t) {
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello world",
"Program output is correct"
);
@@ -50,7 +50,7 @@ test('MOVE', function (t) {
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello world",
"Program output is correct"
);
@@ -328,7 +328,7 @@ test('TESTSET (and)', function (t) {
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello",
"Program output is correct"
);
@@ -353,7 +353,7 @@ test('TESTSET (or)', function (t) {
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello",
"Program output is correct"
);
@@ -382,7 +382,7 @@ test('TEST (true)', function (t) {
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello",
"Program output is correct"
);
@@ -411,7 +411,7 @@ test('TEST (false)', function (t) {
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"goodbye",
"Program output is correct"
);
@@ -532,7 +532,7 @@ test('SETUPVAL, GETUPVAL', function (t) {
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"world",
"Program output is correct"
);
@@ -594,7 +594,7 @@ test('SELF', function (t) {
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello",
"Program output is correct"
);
@@ -794,8 +794,8 @@ test('CONCAT', function (t) {
}, "Program executed without errors");
t.strictEqual(
- lapi.lua_tostring(L, -1),
+ lapi.lua_tojsstring(L, -1),
"hello 2 you",
"Program output is correct"
);
-}); \ No newline at end of file
+});