summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package.json2
-rw-r--r--tests/defs.js102
-rw-r--r--tests/lapi.js40
-rw-r--r--tests/lbaselib.js32
-rw-r--r--tests/lcorolib.js10
-rw-r--r--tests/ldblib.js33
-rw-r--r--tests/ldebug.js8
-rw-r--r--tests/lexparse.js57
-rw-r--r--tests/lmathlib.js38
-rw-r--r--tests/load.js18
-rw-r--r--tests/loadlib.js12
-rw-r--r--tests/loslib.js15
-rw-r--r--tests/lstrlib.js50
-rw-r--r--tests/ltablib.js16
-rw-r--r--tests/ltm.js34
-rw-r--r--tests/lua.js97
-rw-r--r--tests/lutf8lib.js15
-rw-r--r--tests/lvm.js58
-rw-r--r--tests/test-suite/constructs.js152
-rw-r--r--tests/test-suite/db.js16
-rw-r--r--tests/test-suite/ltests.js743
-rw-r--r--tests/test-suite/strings.js116
-rw-r--r--tests/tests.js6
23 files changed, 807 insertions, 863 deletions
diff --git a/package.json b/package.json
index 526a650..6bbad0a 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,7 @@
},
"scripts": {
"build": "webpack",
- "lint": "eslint src/",
+ "lint": "eslint src/ tests/",
"test": "tape tests/*.js tests/test-suite/*.js | faucet",
"test-inprogress": "tape tests/test-suite/inprogress/*.js | faucet"
},
diff --git a/tests/defs.js b/tests/defs.js
index 9fd7f3b..8c0098a 100644
--- a/tests/defs.js
+++ b/tests/defs.js
@@ -3,87 +3,87 @@ const test = require('tape');
const defs = require('../src/defs.js');
const unicode_tests = [
- {
+ {
description: "Convert normal ascii string",
- literal: "foo",
- byte_array: ["f".charCodeAt(0), "o".charCodeAt(0), "o".charCodeAt(0)]
+ literal: "foo",
+ byte_array: ["f".charCodeAt(0), "o".charCodeAt(0), "o".charCodeAt(0)]
},
- {
+ {
description: "Convert ascii string containing null byte",
- literal: "fo\0o",
- byte_array: ["f".charCodeAt(0), "o".charCodeAt(0), 0, "o".charCodeAt(0)]
+ literal: "fo\0o",
+ byte_array: ["f".charCodeAt(0), "o".charCodeAt(0), 0, "o".charCodeAt(0)]
},
- {
+ {
description: "Convert string with BMP unicode chars",
- literal: "Café",
- byte_array: [67, 97, 102, 195, 169]
+ literal: "Café",
+ byte_array: [67, 97, 102, 195, 169]
},
- {
+ {
description: "Convert string with codepoint in PUA (U+E000 to U+F8FF)",
- literal: "",
- byte_array: [239, 163, 191]
+ literal: "",
+ byte_array: [239, 163, 191]
},
- {
+ {
description: "Convert string with surrogate pair",
- literal: "❤️🍾",
- byte_array: [226, 157, 164, 239, 184, 143, 240, 159, 141, 190]
+ literal: "❤️🍾",
+ byte_array: [226, 157, 164, 239, 184, 143, 240, 159, 141, 190]
},
- {
+ {
description: "Convert string with broken surrogate pair",
- literal: "\uD800a",
- byte_array: [237, 160, 128, 97]
+ literal: "\uD800a",
+ byte_array: [237, 160, 128, 97]
},
- {
+ {
description: "Convert string with broken surrogate pair at end of string",
- literal: "\uD823",
- byte_array: [237, 160, 163]
+ literal: "\uD823",
+ byte_array: [237, 160, 163]
}
];
test('to_luastring', function (t) {
- t.plan(unicode_tests.length);
+ t.plan(unicode_tests.length);
- unicode_tests.forEach(function(v) {
- t.deepEqual(defs.to_luastring(v.literal), v.byte_array, v.description);
- });
+ unicode_tests.forEach(function(v) {
+ t.deepEqual(defs.to_luastring(v.literal), v.byte_array, v.description);
+ });
});
test('to_jsstring', function (t) {
- t.plan(unicode_tests.length);
+ t.plan(unicode_tests.length);
- unicode_tests.forEach(function(v) {
- t.deepEqual(defs.to_jsstring(v.byte_array), v.literal, v.description);
- });
+ unicode_tests.forEach(function(v) {
+ t.deepEqual(defs.to_jsstring(v.byte_array), v.literal, v.description);
+ });
});
test('to_jsstring fails on invalid unicode', function (t) {
- t.plan(7);
+ t.plan(7);
- t.throws(function() {
- defs.to_jsstring([165]);
- }, "non-utf8 char");
+ t.throws(function() {
+ defs.to_jsstring([165]);
+ }, "non-utf8 char");
- t.throws(function() {
- defs.to_jsstring([208, 60]);
- }, "invalid continuation byte");
+ t.throws(function() {
+ defs.to_jsstring([208, 60]);
+ }, "invalid continuation byte");
- t.throws(function() {
- defs.to_jsstring([225, 60, 145]);
- }, "invalid continuation byte");
+ t.throws(function() {
+ defs.to_jsstring([225, 60, 145]);
+ }, "invalid continuation byte");
- t.throws(function() {
- defs.to_jsstring([225, 145, 60]);
- }, "invalid continuation byte");
+ t.throws(function() {
+ defs.to_jsstring([225, 145, 60]);
+ }, "invalid continuation byte");
- t.throws(function() {
- defs.to_jsstring([242, 60, 145, 145]);
- }, "invalid continuation byte");
+ t.throws(function() {
+ defs.to_jsstring([242, 60, 145, 145]);
+ }, "invalid continuation byte");
- t.throws(function() {
- defs.to_jsstring([242, 145, 60, 145]);
- }, "invalid continuation byte");
+ t.throws(function() {
+ defs.to_jsstring([242, 145, 60, 145]);
+ }, "invalid continuation byte");
- t.throws(function() {
- defs.to_jsstring([242, 145, 145, 60]);
- }, "invalid continuation byte");
+ t.throws(function() {
+ defs.to_jsstring([242, 145, 145, 60]);
+ }, "invalid continuation byte");
});
diff --git a/tests/lapi.js b/tests/lapi.js
index b764064..5a6785d 100644
--- a/tests/lapi.js
+++ b/tests/lapi.js
@@ -10,7 +10,7 @@ const lua = require('../src/lua.js');
test('luaL_newstate, lua_pushnil, luaL_typename', function (t) {
let L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -31,7 +31,7 @@ test('luaL_newstate, lua_pushnil, luaL_typename', function (t) {
test('lua_pushnumber', function (t) {
let L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -58,7 +58,7 @@ test('lua_pushnumber', function (t) {
test('lua_pushinteger', function (t) {
let L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -85,7 +85,7 @@ test('lua_pushinteger', function (t) {
test('lua_pushliteral', function (t) {
let L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -112,7 +112,7 @@ test('lua_pushliteral', function (t) {
test('lua_pushboolean', function (t) {
let L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -139,7 +139,7 @@ test('lua_pushboolean', function (t) {
test('lua_pushvalue', function (t) {
let L;
-
+
t.plan(5);
t.doesNotThrow(function () {
@@ -180,7 +180,7 @@ test('lua_pushvalue', function (t) {
test('lua_pushjsclosure', function (t) {
let L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -206,7 +206,7 @@ test('lua_pushjsclosure', function (t) {
test('lua_pushjsfunction', function (t) {
let L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -231,7 +231,7 @@ test('lua_pushjsfunction', function (t) {
test('lua_call (calling a light JS function)', function (t) {
let L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -259,7 +259,7 @@ test('lua_call (calling a light JS function)', function (t) {
test('lua_call (calling a JS closure)', function (t) {
let L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -288,7 +288,7 @@ test('lua_call (calling a JS closure)', function (t) {
test('lua_pcall (calling a light JS function)', function (t) {
let L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -316,7 +316,7 @@ test('lua_pcall (calling a light JS function)', function (t) {
test('lua_pcall that breaks', function (t) {
let L;
-
+
t.plan(1);
t.doesNotThrow(function () {
@@ -339,7 +339,7 @@ test('lua_pcall that breaks', function (t) {
test('lua_pop', function (t) {
let L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -383,10 +383,10 @@ test('lua_load with no chunkname', function (t) {
test('lua_load and lua_call it', function (t) {
let luaCode = `
- local a = "JS > Lua > JS \o/"
+ local a = "JS > Lua > JS \\o/"
return a
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -403,7 +403,7 @@ test('lua_load and lua_call it', function (t) {
t.strictEqual(
lua.lua_tojsstring(L, -1),
- "JS > Lua > JS \o/",
+ "JS > Lua > JS \\o/",
"Correct element(s) on the stack"
);
});
@@ -413,7 +413,7 @@ test('lua script reads js upvalues', function (t) {
let luaCode = `
return js .. " world"
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -439,7 +439,7 @@ test('lua script reads js upvalues', function (t) {
test('lua_createtable', function (t) {
let L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -458,7 +458,7 @@ test('lua_createtable', function (t) {
test('lua_newtable', function (t) {
let L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -477,7 +477,7 @@ test('lua_newtable', function (t) {
test('lua_settable, lua_gettable', function (t) {
let L;
-
+
t.plan(2);
t.doesNotThrow(function () {
diff --git a/tests/lbaselib.js b/tests/lbaselib.js
index fcd8356..6558c1f 100644
--- a/tests/lbaselib.js
+++ b/tests/lbaselib.js
@@ -11,7 +11,7 @@ test('print', function (t) {
let luaCode = `
print("hello", "world", 123)
`, L;
-
+
t.plan(1);
t.doesNotThrow(function () {
@@ -43,7 +43,7 @@ test('setmetatable, getmetatable', function (t) {
return t[1], getmetatable(t)
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -86,7 +86,7 @@ test('rawequal', function (t) {
return rawequal(t1, t2), t1 == t2
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -130,7 +130,7 @@ test('rawset, rawget', function (t) {
return rawget(t, "yo"), t["yo"], rawget(t, "yoyo"), t["yoyo"]
`, L;
-
+
t.plan(5);
t.doesNotThrow(function () {
@@ -175,7 +175,7 @@ test('type', function (t) {
let luaCode = `
return type(1), type(true), type("hello"), type({}), type(nil)
`, L;
-
+
t.plan(6);
t.doesNotThrow(function () {
@@ -226,7 +226,7 @@ test('error', function (t) {
let luaCode = `
error("you fucked up")
`, L;
-
+
t.plan(1);
t.throws(function () {
@@ -247,7 +247,7 @@ test('error, protected', function (t) {
let luaCode = `
error("you fucked up")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -277,7 +277,7 @@ test('pcall', function (t) {
return pcall(willFail)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -311,7 +311,7 @@ test('xpcall', function (t) {
return xpcall(willFail, msgh)
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -349,7 +349,7 @@ test('ipairs', function (t) {
return sum
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -376,7 +376,7 @@ test('select', function (t) {
let luaCode = `
return {select('#', 1, 2, 3)}, {select(2, 1, 2, 3)}, {select(-2, 1, 2, 3)}
`, L;
-
+
t.plan(4);
t.doesNotThrow(function () {
@@ -469,7 +469,7 @@ test('assert', function (t) {
let luaCode = `
assert(1 < 0, "this doesn't makes sense")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -495,7 +495,7 @@ test('rawlen', function (t) {
let luaCode = `
return rawlen({1, 2, 3}), rawlen('hello')
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -540,7 +540,7 @@ test('next', function (t) {
return total
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -579,7 +579,7 @@ test('pairs', function (t) {
return total
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -627,7 +627,7 @@ test('pairs with __pairs', function (t) {
return total
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
diff --git a/tests/lcorolib.js b/tests/lcorolib.js
index 4faf13b..e1868b2 100644
--- a/tests/lcorolib.js
+++ b/tests/lcorolib.js
@@ -20,7 +20,7 @@ test('coroutine.create, coroutine.yield, coroutine.resume', function (t) {
return pow
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -61,7 +61,7 @@ test('coroutine.status', function (t) {
return s1, s2
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -100,7 +100,7 @@ test('coroutine.isyieldable', function (t) {
return yieldable, coroutine.isyieldable()
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -139,7 +139,7 @@ test('coroutine.running', function (t) {
return running, ismain
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -178,7 +178,7 @@ test('coroutine.wrap', function (t) {
return pow
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
diff --git a/tests/ldblib.js b/tests/ldblib.js
index 7f39c09..209e60e 100644
--- a/tests/ldblib.js
+++ b/tests/ldblib.js
@@ -23,7 +23,7 @@ test('debug.sethook', function (t) {
return result
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -47,7 +47,6 @@ test('debug.sethook', function (t) {
"return count line count line count line call count line return count line count line call count line return count line count line call count line return count line ",
"Correct element(s) on the stack"
);
-
});
@@ -67,7 +66,7 @@ test('debug.gethook', function (t) {
return debug.gethook()
`, L;
-
+
t.plan(5);
t.doesNotThrow(function () {
@@ -103,7 +102,6 @@ test('debug.gethook', function (t) {
1,
"Correct element(s) on the stack"
);
-
});
@@ -127,7 +125,7 @@ test('debug.getlocal', function (t) {
return result
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -151,7 +149,6 @@ test('debug.getlocal', function (t) {
"alocal alocalanother anotherinfunction infunctionanotherin anotherin",
"Correct element(s) on the stack"
);
-
});
test('debug.setlocal', function (t) {
@@ -175,7 +172,7 @@ test('debug.setlocal', function (t) {
return alocal, another, a, b
`, L;
-
+
t.plan(6);
t.doesNotThrow(function () {
@@ -217,7 +214,6 @@ test('debug.setlocal', function (t) {
4,
"Correct element(s) on the stack"
);
-
});
test('debug.upvalueid', function (t) {
@@ -230,7 +226,7 @@ test('debug.upvalueid', function (t) {
return debug.upvalueid(l, 1)
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -253,7 +249,6 @@ test('debug.upvalueid', function (t) {
lua.lua_touserdata(L, -1),
"Correct element(s) on the stack"
);
-
});
@@ -274,7 +269,7 @@ test('debug.upvaluejoin', function (t) {
return l1()
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -298,7 +293,6 @@ test('debug.upvaluejoin', function (t) {
"upvalue2",
"Correct element(s) on the stack"
);
-
});
@@ -319,7 +313,7 @@ test('debug.traceback (with a global)', function (t) {
return trace
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -340,8 +334,7 @@ test('debug.traceback (with a global)', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lua.lua_tojsstring(L, -1),
-`stack traceback:
+ lua.lua_tojsstring(L, -1), `stack traceback:
\t[string "traceback-test"]:9: in function 'rec'
\t[string "traceback-test"]:7: in function 'rec'
\t[string "traceback-test"]:7: in function 'rec'
@@ -356,7 +349,6 @@ test('debug.traceback (with a global)', function (t) {
\t[string "traceback-test"]:13: in main chunk`,
"Correct element(s) on the stack"
);
-
});
@@ -378,7 +370,7 @@ test('debug.traceback (with a upvalue)', function (t) {
return trace
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -399,8 +391,7 @@ test('debug.traceback (with a upvalue)', function (t) {
}, "Lua program ran without error");
t.strictEqual(
- lua.lua_tojsstring(L, -1),
-`stack traceback:
+ lua.lua_tojsstring(L, -1), `stack traceback:
\t[string "traceback-test"]:10: in upvalue 'rec'
\t[string "traceback-test"]:8: in upvalue 'rec'
\t[string "traceback-test"]:8: in upvalue 'rec'
@@ -415,7 +406,6 @@ test('debug.traceback (with a upvalue)', function (t) {
\t[string "traceback-test"]:14: in main chunk`,
"Correct element(s) on the stack"
);
-
});
test('debug.getinfo', function (t) {
@@ -432,7 +422,7 @@ test('debug.getinfo', function (t) {
return d1.short_src, d1.nups, d1.what, d1.nparams,
d2.short_src, d2.nups, d2.what, d2.nparams
`, L;
-
+
t.plan(10);
t.doesNotThrow(function () {
@@ -499,5 +489,4 @@ test('debug.getinfo', function (t) {
0,
"Correct element(s) on the stack"
);
-
});
diff --git a/tests/ldebug.js b/tests/ldebug.js
index 8809bde..857345e 100644
--- a/tests/ldebug.js
+++ b/tests/ldebug.js
@@ -11,7 +11,7 @@ test('luaG_typeerror', function (t) {
local a = true
return #a
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -66,7 +66,7 @@ test('luaG_typeerror', function (t) {
local a = true
return a.yo
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -145,7 +145,7 @@ test('luaG_opinterror', function (t) {
let luaCode = `
return {} + 'hello'
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -171,7 +171,7 @@ test('luaG_tointerror', function (t) {
let luaCode = `
return 123.5 & 12
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
diff --git a/tests/lexparse.js b/tests/lexparse.js
index ecb386f..e7ba0c5 100644
--- a/tests/lexparse.js
+++ b/tests/lexparse.js
@@ -2,9 +2,6 @@
const test = require('tape');
-const tests = require("./tests.js");
-const toByteCode = tests.toByteCode;
-
const lua = require('../src/lua.js');
const lauxlib = require('../src/lauxlib.js');
const lualib = require('../src/lualib.js');
@@ -17,7 +14,7 @@ test('LOADK, RETURN', function (t) {
local a = "hello world"
return a
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -57,7 +54,7 @@ test('MOVE', function (t) {
local b = a
return b
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -97,7 +94,7 @@ test('Binary op', function (t) {
local b = 10
return a + b, a - b, a * b, a / b, a % b, a^b, a // b, a & b, a | b, a ~ b, a << b, a >> b
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -137,7 +134,7 @@ test('Unary op, LOADBOOL', function (t) {
local b = false
return -a, not b, ~a
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -175,7 +172,7 @@ test('NEWTABLE', function (t) {
local a = {}
return a
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -217,7 +214,7 @@ test('CALL', function (t) {
return c
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -263,7 +260,7 @@ test('Multiple return', function (t) {
return c, d, e
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -304,7 +301,7 @@ test('TAILCALL', function (t) {
return f(1,2)
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -345,7 +342,7 @@ test('VARARG', function (t) {
return f(1,2,3)
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -384,7 +381,7 @@ test('LE, JMP', function (t) {
return a >= b
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -423,7 +420,7 @@ test('LT', function (t) {
return a > b
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -462,7 +459,7 @@ test('EQ', function (t) {
return a == b
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -502,7 +499,7 @@ test('TESTSET (and)', function (t) {
return a and b
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -542,7 +539,7 @@ test('TESTSET (or)', function (t) {
return a or b
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -586,7 +583,7 @@ test('TEST (false)', function (t) {
return "goodbye"
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -629,7 +626,7 @@ test('FORPREP, FORLOOP (int)', function (t) {
return total
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -672,7 +669,7 @@ test('FORPREP, FORLOOP (float)', function (t) {
return total
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -714,7 +711,7 @@ test('SETTABLE, GETTABLE', function (t) {
return t
`, L;
-
+
t.plan(4);
t.doesNotThrow(function () {
@@ -765,7 +762,7 @@ test('SETUPVAL, GETUPVAL', function (t) {
return f()
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -807,7 +804,7 @@ test('SETTABUP, GETTABUP', function (t) {
return t
`, L;
-
+
t.plan(4);
t.doesNotThrow(function () {
@@ -857,7 +854,7 @@ test('SELF', function (t) {
return t:get()
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -896,7 +893,7 @@ test('SETLIST', function (t) {
return t
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -939,7 +936,7 @@ test('Variable SETLIST', function (t) {
return t
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -977,7 +974,7 @@ test('Long SETLIST', function (t) {
return t
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -1032,7 +1029,7 @@ test('TFORCALL, TFORLOOP', function (t) {
return r
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -1073,7 +1070,7 @@ test('LEN', function (t) {
return #t, #t2, #s
`, L;
-
+
t.plan(5);
t.doesNotThrow(function () {
@@ -1122,7 +1119,7 @@ test('CONCAT', function (t) {
let luaCode = `
return "hello " .. 2 .. " you"
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
diff --git a/tests/lmathlib.js b/tests/lmathlib.js
index b227af0..5c307a5 100644
--- a/tests/lmathlib.js
+++ b/tests/lmathlib.js
@@ -12,7 +12,7 @@ test('math.abs, math.sin, math.cos, math.tan, math.asin, math.acos, math.atan',
return math.abs(-10), math.abs(-10.5), math.cos(10), math.tan(10),
math.asin(1), math.acos(0.5), math.atan(10)
`, L;
-
+
t.plan(8);
t.doesNotThrow(function () {
@@ -75,7 +75,7 @@ test('math.ceil, math.floor', function (t) {
let luaCode = `
return math.ceil(10.5), math.floor(10.5)
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -101,7 +101,6 @@ test('math.ceil, math.floor', function (t) {
10,
"Correct element(s) on the stack"
);
-
});
@@ -109,7 +108,7 @@ test('math.deg, math.rad', function (t) {
let luaCode = `
return math.deg(10), math.rad(10)
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -135,7 +134,6 @@ test('math.deg, math.rad', function (t) {
0.17453292519943295,
"Correct element(s) on the stack"
);
-
});
@@ -143,7 +141,7 @@ test('math.log', function (t) {
let luaCode = `
return math.log(10), math.log(10, 2), math.log(10, 10)
`, L;
-
+
t.plan(4);
t.doesNotThrow(function () {
@@ -175,7 +173,6 @@ test('math.log', function (t) {
1,
"Correct element(s) on the stack"
);
-
});
@@ -183,7 +180,7 @@ test('math.exp', function (t) {
let luaCode = `
return math.exp(10)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -203,7 +200,6 @@ test('math.exp', function (t) {
22026.465794806718,
"Correct element(s) on the stack"
);
-
});
@@ -211,7 +207,7 @@ test('math.min, math.max', function (t) {
let luaCode = `
return math.max(10, 5, 23), math.min(10, 5, 23)
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -237,7 +233,6 @@ test('math.min, math.max', function (t) {
5,
"Correct element(s) on the stack"
);
-
});
@@ -245,7 +240,7 @@ test('math.random', function (t) {
let luaCode = `
return math.random(), math.random(10, 15)
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -269,7 +264,6 @@ test('math.random', function (t) {
10 <= lua.lua_tonumber(L, -1) <= 15,
"Correct element(s) on the stack"
);
-
});
@@ -277,7 +271,7 @@ test('math.sqrt', function (t) {
let luaCode = `
return math.sqrt(10)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -297,7 +291,6 @@ test('math.sqrt', function (t) {
3.1622776601683795,
"Correct element(s) on the stack"
);
-
});
@@ -305,7 +298,7 @@ test('math.tointeger', function (t) {
let luaCode = `
return math.tointeger('10')
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -325,7 +318,6 @@ test('math.tointeger', function (t) {
10,
"Correct element(s) on the stack"
);
-
});
@@ -333,7 +325,7 @@ test('math.type', function (t) {
let luaCode = `
return math.type(10), math.type(10.5), math.type('hello')
`, L;
-
+
t.plan(4);
t.doesNotThrow(function () {
@@ -365,7 +357,6 @@ test('math.type', function (t) {
null,
"Correct element(s) on the stack"
);
-
});
@@ -373,7 +364,7 @@ test('math.ult', function (t) {
let luaCode = `
return math.tointeger('10')
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -393,7 +384,6 @@ test('math.ult', function (t) {
true,
"Correct element(s) on the stack"
);
-
});
@@ -401,7 +391,7 @@ test('math.fmod', function (t) {
let luaCode = `
return math.fmod(2,5)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -421,7 +411,6 @@ test('math.fmod', function (t) {
2,
"Correct element(s) on the stack"
);
-
});
@@ -429,7 +418,7 @@ test('math.modf', function (t) {
let luaCode = `
return math.modf(3.4, 0.6)
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -455,5 +444,4 @@ test('math.modf', function (t) {
0.3999999999999999,
"Correct element(s) on the stack"
);
-
});
diff --git a/tests/load.js b/tests/load.js
index a385959..49756a5 100644
--- a/tests/load.js
+++ b/tests/load.js
@@ -15,7 +15,7 @@ test('luaL_loadstring', function (t) {
local a = "hello world"
return a
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -39,7 +39,6 @@ test('luaL_loadstring', function (t) {
"hello world",
"Correct element(s) on the stack"
);
-
});
@@ -48,7 +47,7 @@ test('load', function (t) {
local f = load("return 'js running lua running lua'")
return f()
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -72,7 +71,6 @@ test('load', function (t) {
"js running lua running lua",
"Correct element(s) on the stack"
);
-
});
@@ -81,7 +79,7 @@ test('luaL_loadbuffer', function (t) {
local a = "hello world"
return a
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -107,7 +105,6 @@ test('luaL_loadbuffer', function (t) {
"hello world",
"Correct element(s) on the stack"
);
-
});
// TODO: test stdin
@@ -116,7 +113,7 @@ test('loadfile', function (t) {
local f = loadfile("tests/loadfile-test.lua")
return f()
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -140,7 +137,6 @@ test('loadfile', function (t) {
"hello world",
"Correct element(s) on the stack"
);
-
});
@@ -149,7 +145,7 @@ test('loadfile (binary)', function (t) {
local f = loadfile("tests/loadfile-test.bc")
return f()
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -173,7 +169,6 @@ test('loadfile (binary)', function (t) {
"hello world",
"Correct element(s) on the stack"
);
-
});
@@ -181,7 +176,7 @@ test('dofile', function (t) {
let luaCode = `
return dofile("tests/loadfile-test.lua")
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -205,5 +200,4 @@ test('dofile', function (t) {
"hello world",
"Correct element(s) on the stack"
);
-
});
diff --git a/tests/loadlib.js b/tests/loadlib.js
index 5854519..c4c98ea 100644
--- a/tests/loadlib.js
+++ b/tests/loadlib.js
@@ -11,7 +11,7 @@ test('require an existing module', function (t) {
let luaCode = `
return require('os')
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -34,7 +34,6 @@ test('require an existing module', function (t) {
lua.lua_istable(L, -1),
"Correct element(s) on the stack"
);
-
});
@@ -42,7 +41,7 @@ test('require a file', function (t) {
let luaCode = `
return require('tests/module-hello')()
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -66,7 +65,6 @@ test('require a file', function (t) {
"hello from module",
"Correct element(s) on the stack"
);
-
});
@@ -74,7 +72,7 @@ test('package.loadlib', function (t) {
let luaCode = `
return package.loadlib('./tests/lib-hello.js.mod', 'hello')()
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -98,7 +96,6 @@ test('package.loadlib', function (t) {
"hello from js lib",
"Correct element(s) on the stack"
);
-
});
@@ -106,7 +103,7 @@ test('package.searchpath', function (t) {
let luaCode = `
return package.searchpath('module-hello', './?.lua;./tests/?.lua')
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -130,5 +127,4 @@ test('package.searchpath', function (t) {
"./tests/module-hello.lua",
"Correct element(s) on the stack"
);
-
});
diff --git a/tests/loslib.js b/tests/loslib.js
index 5f49043..83d6c81 100644
--- a/tests/loslib.js
+++ b/tests/loslib.js
@@ -11,7 +11,7 @@ test('os.time', function (t) {
let luaCode = `
return os.time()
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -34,7 +34,6 @@ test('os.time', function (t) {
lua.lua_isinteger(L, -1),
"Correct element(s) on the stack"
);
-
});
@@ -46,7 +45,7 @@ test('os.time (with format)', function (t) {
year = 2015
})
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -70,7 +69,6 @@ test('os.time (with format)', function (t) {
new Date(2015, 1, 8, 12, 0, 0, 0).getTime() / 1000,
"Correct element(s) on the stack"
);
-
});
@@ -80,7 +78,7 @@ test('os.difftime', function (t) {
local t2 = os.time()
return os.difftime(t2, t1)
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -103,7 +101,6 @@ test('os.difftime', function (t) {
lua.lua_isnumber(L, -1),
"Correct element(s) on the stack"
);
-
});
@@ -115,7 +112,7 @@ test('os.date', function (t) {
year = 2015
}))
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -139,7 +136,6 @@ test('os.date', function (t) {
"2015-02-08",
"Correct element(s) on the stack"
);
-
});
@@ -147,7 +143,7 @@ test('os.getenv', function (t) {
let luaCode = `
return os.getenv('PATH')
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -170,5 +166,4 @@ test('os.getenv', function (t) {
lua.lua_isstring(L, -1),
"Correct element(s) on the stack"
);
-
});
diff --git a/tests/lstrlib.js b/tests/lstrlib.js
index 817ebcb..a55fca1 100644
--- a/tests/lstrlib.js
+++ b/tests/lstrlib.js
@@ -12,7 +12,7 @@ test('string.len', function (t) {
local a = "world"
return string.len("hello"), a:len()
`, L;
-
+
t.plan(4);
t.doesNotThrow(function () {
@@ -50,7 +50,7 @@ test('string.char', function (t) {
let luaCode = `
return string.char(104, 101, 108, 108, 111)
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -81,7 +81,7 @@ test('string.upper, string.lower', function (t) {
let luaCode = `
return string.upper("hello"), string.lower("HELLO")
`, L;
-
+
t.plan(4);
t.doesNotThrow(function () {
@@ -118,7 +118,7 @@ test('string.rep', function (t) {
let luaCode = `
return string.rep("hello", 3, ", ")
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -149,7 +149,7 @@ test('string.reverse', function (t) {
let luaCode = `
return string.reverse("olleh")
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -180,7 +180,7 @@ test('string.byte', function (t) {
let luaCode = `
return string.byte("hello", 2, 4)
`, L;
-
+
t.plan(5);
t.doesNotThrow(function () {
@@ -223,7 +223,7 @@ test('string.format', function (t) {
let luaCode = `
return string.format("%%%d %010d", 10, 23)
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -254,7 +254,7 @@ test('string.format', function (t) {
let luaCode = `
return string.format("%07X", 0xFFFFFFF)
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -285,7 +285,7 @@ test('string.format', function (t) {
let luaCode = `
return string.format("%q", 'a string with "quotes" and \\n new line')
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -326,7 +326,7 @@ test('string.sub', function (t) {
string.sub("123456789",-4), -- "6789"
string.sub("123456789",-6, -4) -- "456"
`, L;
-
+
t.plan(13);
t.doesNotThrow(function () {
@@ -359,7 +359,7 @@ test('string.sub', function (t) {
t.strictEqual(
lua.lua_tojsstring(L, -9),
- "",
+ "",
"Correct element(s) on the stack"
);
@@ -371,7 +371,7 @@ test('string.sub', function (t) {
t.strictEqual(
lua.lua_tojsstring(L, -7),
- "",
+ "",
"Correct element(s) on the stack"
);
@@ -389,7 +389,7 @@ test('string.sub', function (t) {
t.strictEqual(
lua.lua_tojsstring(L, -4),
- "",
+ "",
"Correct element(s) on the stack"
);
@@ -425,8 +425,8 @@ test('string.dump', function (t) {
end
return string.dump(todump)
- `, L, bytes = [];
-
+ `, L;
+
t.plan(3);
t.doesNotThrow(function () {
@@ -465,7 +465,7 @@ test('string.pack/unpack/packsize', function (t) {
local us1, un, us2 = string.unpack("c5jc3", packed)
return string.packsize("c5jc3"), s1 == us1 and n == un and s2 == us2
`, L;
-
+
t.plan(4);
t.doesNotThrow(function () {
@@ -501,7 +501,7 @@ test('string.find without pattern', function (t) {
let luaCode = `
return string.find("hello to you", " to ")
`, L;
-
+
t.plan(4);
t.doesNotThrow(function () {
@@ -538,7 +538,7 @@ test('string.match', function (t) {
let luaCode = `
return string.match("foo: 123 bar: 456", "(%a+):%s*(%d+)")
`, L;
-
+
t.plan(4);
t.doesNotThrow(function () {
@@ -575,7 +575,7 @@ test('string.find', function (t) {
let luaCode = `
return string.find("foo: 123 bar: 456", "(%a+):%s*(%d+)")
`, L;
-
+
t.plan(6);
t.doesNotThrow(function () {
@@ -631,7 +631,7 @@ test('string.gmatch', function (t) {
return table.unpack(t)
`, L;
-
+
t.plan(6);
t.doesNotThrow(function () {
@@ -680,7 +680,7 @@ test('string.gsub', function (t) {
let luaCode = `
return string.gsub("hello world", "(%w+)", "%1 %1")
`, L;
-
+
t.plan(4);
t.doesNotThrow(function () {
@@ -717,7 +717,7 @@ test('string.gsub (number)', function (t) {
let luaCode = `
return string.gsub("hello world", "%w+", "%0 %0", 1)
`, L;
-
+
t.plan(4);
t.doesNotThrow(function () {
@@ -754,7 +754,7 @@ test('string.gsub (pattern)', function (t) {
let luaCode = `
return string.gsub("hello world from Lua", "(%w+)%s*(%w+)", "%2 %1")
`, L;
-
+
t.plan(4);
t.doesNotThrow(function () {
@@ -793,7 +793,7 @@ test('string.gsub (function)', function (t) {
return load(s)()
end)
`, L;
-
+
t.plan(4);
t.doesNotThrow(function () {
@@ -832,7 +832,7 @@ test('string.gsub (table)', function (t) {
local t = {name="lua", version="5.3"}
return string.gsub("$name-$version.tar.gz", "%$(%w+)", t)
`, L;
-
+
t.plan(4);
t.doesNotThrow(function () {
diff --git a/tests/ltablib.js b/tests/ltablib.js
index e2e8825..2adf1fe 100644
--- a/tests/ltablib.js
+++ b/tests/ltablib.js
@@ -22,7 +22,7 @@ test('table.concat', function (t) {
let luaCode = `
return table.concat({1, 2, 3, 4, 5, 6, 7}, ",", 3, 5)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -49,7 +49,7 @@ test('table.pack', function (t) {
let luaCode = `
return table.pack(1, 2, 3)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -78,7 +78,7 @@ test('table.unpack', function (t) {
let luaCode = `
return table.unpack({1, 2, 3, 4, 5}, 2, 4)
`, L;
-
+
t.plan(4);
t.doesNotThrow(function () {
@@ -120,7 +120,7 @@ test('table.insert', function (t) {
table.insert(t, 2, 2)
return t
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -152,7 +152,7 @@ test('table.remove', function (t) {
table.remove(t, 3)
return t
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -183,7 +183,7 @@ test('table.move', function (t) {
local t2 = {1, 2, nil, nil, nil, 6}
return table.move(t1, 1, #t1, 3, t2)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -214,7 +214,7 @@ test('table.sort (<)', function (t) {
table.sort(t)
return t
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -245,7 +245,7 @@ test('table.sort with cmp function', function (t) {
end)
return t
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
diff --git a/tests/ltm.js b/tests/ltm.js
index 86fa52c..0d9bc1a 100644
--- a/tests/ltm.js
+++ b/tests/ltm.js
@@ -12,7 +12,7 @@ test('__index, __newindex: with actual table', function (t) {
local t = {yo=1}
return t.yo, t.lo
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -42,7 +42,7 @@ test('__newindex: with non table', function (t) {
local t = "a string"
t.yo = "hello"
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -73,7 +73,7 @@ test('__index function in metatable', function (t) {
return t.yo
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -113,7 +113,7 @@ test('__newindex function in metatable', function (t) {
return t.yo
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -151,7 +151,7 @@ test('__index table in metatable', function (t) {
return t.yo
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -192,7 +192,7 @@ test('__newindex table in metatable', function (t) {
return t.yo, mmt.yo
`, L;
-
+
t.plan(4);
t.doesNotThrow(function () {
@@ -244,7 +244,7 @@ test('__index table with own metatable', function (t) {
return t.yo
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -295,7 +295,7 @@ test('__newindex table with own metatable', function (t) {
return t.yo, up
`, L;
-
+
t.plan(4);
t.doesNotThrow(function () {
@@ -394,7 +394,7 @@ test('binary __xxx functions in metatable', function (t) {
t << 1,
t >> 1
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -444,7 +444,7 @@ test('__eq', function (t) {
return t == {}
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -480,7 +480,7 @@ test('__lt', function (t) {
return t < {}
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -516,7 +516,7 @@ test('__le', function (t) {
return t <= {}
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -552,7 +552,7 @@ test('__le that uses __lt', function (t) {
return {} <= t
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -592,7 +592,7 @@ test('__unm, __bnot', function (t) {
return -t, ~t
`, L;
-
+
t.plan(4);
t.doesNotThrow(function () {
@@ -635,7 +635,7 @@ test('__len', function (t) {
return #t
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -672,7 +672,7 @@ test('__concat', function (t) {
return t .. " world"
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -709,7 +709,7 @@ test('__call', function (t) {
return t("world","wow")
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
diff --git a/tests/lua.js b/tests/lua.js
index 487f748..82df6ff 100644
--- a/tests/lua.js
+++ b/tests/lua.js
@@ -9,85 +9,80 @@ const lapi = require('../src/lapi.js');
// TODO: remove
-if (false) {
- test('locals.lua', function (t) {
- let luaCode = `
- _soft = true
- require = function(lib) return _G[lib] end -- NYI
- return dofile("tests/lua-tests/locals.lua")
- `, L;
-
- t.plan(2);
+test.skip('locals.lua', function (t) {
+ let luaCode = `
+ _soft = true
+ require = function(lib) return _G[lib] end -- NYI
+ return dofile("tests/lua-tests/locals.lua")
+ `, L;
- t.doesNotThrow(function () {
+ t.plan(2);
- L = lauxlib.luaL_newstate();
+ t.doesNotThrow(function () {
- lualib.luaL_openlibs(L);
+ L = lauxlib.luaL_newstate();
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lualib.luaL_openlibs(L);
- }, "Lua program loaded without error");
+ lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
- t.doesNotThrow(function () {
+ }, "Lua program loaded without error");
- lapi.lua_call(L, 0, -1);
+ t.doesNotThrow(function () {
- }, "Lua program ran without error");
+ lapi.lua_call(L, 0, -1);
- });
+ }, "Lua program ran without error");
+});
- test('constructs.lua', function (t) {
- let luaCode = `
- _soft = true
- require = function(lib) return _G[lib] end -- NYI
- return dofile("tests/lua-tests/constructs.lua")
- `, L;
-
- t.plan(2);
+test.skip('constructs.lua', function (t) {
+ let luaCode = `
+ _soft = true
+ require = function(lib) return _G[lib] end -- NYI
+ return dofile("tests/lua-tests/constructs.lua")
+ `, L;
- t.doesNotThrow(function () {
+ t.plan(2);
- L = lauxlib.luaL_newstate();
+ t.doesNotThrow(function () {
- lualib.luaL_openlibs(L);
+ L = lauxlib.luaL_newstate();
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lualib.luaL_openlibs(L);
- }, "Lua program loaded without error");
+ lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
- t.doesNotThrow(function () {
+ }, "Lua program loaded without error");
- lapi.lua_call(L, 0, -1);
+ t.doesNotThrow(function () {
- }, "Lua program ran without error");
+ lapi.lua_call(L, 0, -1);
- });
+ }, "Lua program ran without error");
+});
- test('strings.lua', function (t) {
- let luaCode = `
- return dofile("tests/lua-tests/strings.lua")
- `, L;
-
- t.plan(2);
+test.skip('strings.lua', function (t) {
+ let luaCode = `
+ return dofile("tests/lua-tests/strings.lua")
+ `, L;
- t.doesNotThrow(function () {
+ t.plan(2);
- L = lauxlib.luaL_newstate();
+ t.doesNotThrow(function () {
- lualib.luaL_openlibs(L);
+ L = lauxlib.luaL_newstate();
- lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
+ lualib.luaL_openlibs(L);
- }, "Lua program loaded without error");
+ lauxlib.luaL_loadstring(L, lua.to_luastring(luaCode));
- t.doesNotThrow(function () {
+ }, "Lua program loaded without error");
- lapi.lua_call(L, 0, -1);
+ t.doesNotThrow(function () {
- }, "Lua program ran without error");
+ lapi.lua_call(L, 0, -1);
- });
-}
+ }, "Lua program ran without error");
+});
diff --git a/tests/lutf8lib.js b/tests/lutf8lib.js
index cff7472..ae40d3c 100644
--- a/tests/lutf8lib.js
+++ b/tests/lutf8lib.js
@@ -10,7 +10,7 @@ test('utf8.offset', function (t) {
let luaCode = `
return utf8.offset("( ͡° ͜ʖ ͡° )", 5)
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -34,7 +34,6 @@ test('utf8.offset', function (t) {
7,
"Correct element(s) on the stack"
);
-
});
@@ -42,7 +41,7 @@ test('utf8.codepoint', function (t) {
let luaCode = `
return utf8.codepoint("( ͡° ͜ʖ ͡° )", 5, 8)
`, L;
-
+
t.plan(5);
t.doesNotThrow(function () {
@@ -78,7 +77,6 @@ test('utf8.codepoint', function (t) {
860,
"Correct element(s) on the stack"
);
-
});
@@ -86,7 +84,7 @@ test('utf8.char', function (t) {
let luaCode = `
return utf8.char(40, 32, 865, 176, 32, 860, 662, 32, 865, 176, 32, 41)
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -110,7 +108,6 @@ test('utf8.char', function (t) {
"( ͡° ͜ʖ ͡° )",
"Correct element(s) on the stack"
);
-
});
@@ -118,7 +115,7 @@ test('utf8.len', function (t) {
let luaCode = `
return utf8.len("( ͡° ͜ʖ ͡° )")
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -142,7 +139,6 @@ test('utf8.len', function (t) {
12,
"Correct element(s) on the stack"
);
-
});
@@ -155,7 +151,7 @@ test('utf8.codes', function (t) {
end
return results
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -179,5 +175,4 @@ test('utf8.codes', function (t) {
"[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"
);
-
});
diff --git a/tests/lvm.js b/tests/lvm.js
index 226583b..209329e 100644
--- a/tests/lvm.js
+++ b/tests/lvm.js
@@ -11,7 +11,7 @@ test('LOADK, RETURN', function (t) {
local a = "hello world"
return a
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -33,7 +33,7 @@ test('MOVE', function (t) {
local b = a
return b
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -54,7 +54,7 @@ test('Binary op', function (t) {
local b = 10
return a + b, a - b, a * b, a / b, a % b, a^b, a // b, a & b, a | b, a ~ b, a << b, a >> b
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -76,7 +76,7 @@ test('Unary op, LOADBOOL', function (t) {
local b = false
return -a, not b, ~a
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -97,7 +97,7 @@ test('NEWTABLE', function (t) {
local a = {}
return a
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -122,7 +122,7 @@ test('CALL', function (t) {
return c
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -152,7 +152,7 @@ test('Multiple return', function (t) {
return c, d, e
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -176,7 +176,7 @@ test('TAILCALL', function (t) {
return f(1,2)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -200,7 +200,7 @@ test('VARARG', function (t) {
return f(1,2,3)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -222,7 +222,7 @@ test('LE, JMP', function (t) {
return a >= b
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -244,7 +244,7 @@ test('LT', function (t) {
return a > b
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -266,7 +266,7 @@ test('EQ', function (t) {
return a == b
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -289,7 +289,7 @@ test('TESTSET (and)', function (t) {
return a and b
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -312,7 +312,7 @@ test('TESTSET (or)', function (t) {
return a or b
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -339,7 +339,7 @@ test('TEST (true)', function (t) {
return "goodbye"
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -366,7 +366,7 @@ test('TEST (false)', function (t) {
return "goodbye"
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -392,7 +392,7 @@ test('FORPREP, FORLOOP (int)', function (t) {
return total
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -418,7 +418,7 @@ test('FORPREP, FORLOOP (float)', function (t) {
return total
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -443,7 +443,7 @@ test('SETTABLE, GETTABLE', function (t) {
return t
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -477,7 +477,7 @@ test('SETUPVAL, GETUPVAL', function (t) {
return f()
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -502,7 +502,7 @@ test('SETTABUP, GETTABUP', function (t) {
return t
`, L;
-
+
t.plan(3);
t.doesNotThrow(function () {
@@ -535,7 +535,7 @@ test('SELF', function (t) {
return t:get()
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -557,7 +557,7 @@ test('SETLIST', function (t) {
return t
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -583,7 +583,7 @@ test('Variable SETLIST', function (t) {
return t
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -605,7 +605,7 @@ test('Long SETLIST', function (t) {
return t
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -627,7 +627,7 @@ test('Long SETLIST', function (t) {
//
// return t
// `, L;
-//
+//
// t.plan(1);
//
//
@@ -667,7 +667,7 @@ test('TFORCALL, TFORLOOP', function (t) {
return r
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -691,7 +691,7 @@ test('LEN', function (t) {
return #t, #t2, #s
`, L;
-
+
t.plan(4);
t.doesNotThrow(function () {
@@ -723,7 +723,7 @@ test('CONCAT', function (t) {
let luaCode = `
return "hello " .. 2 .. " you"
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
diff --git a/tests/test-suite/constructs.js b/tests/test-suite/constructs.js
index f180195..89bcce7 100644
--- a/tests/test-suite/constructs.js
+++ b/tests/test-suite/constructs.js
@@ -19,7 +19,7 @@ test('[test-suite] constructs: testing semicolons', function (t) {
; do ; a = 3; assert(a == 3) end;
;
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -45,7 +45,7 @@ test('[test-suite] constructs: invalid operations should not raise errors when n
let luaCode = `
if false then a = 3 // 0; a = 0 % 0 end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -110,7 +110,7 @@ test('[test-suite] constructs: testing priorities', function (t) {
assert(1234567890 == tonumber('1234567890') and 1234567890+1 == 1234567891)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -296,7 +296,7 @@ test('[test-suite] constructs: silly loops', function (t) {
a,b = F(1)~=nil; assert(a == true and b == nil);
a,b = F(nil)==nil; assert(a == true and b == nil)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -317,94 +317,92 @@ test('[test-suite] constructs: silly loops', function (t) {
});
-if (false) {
- test('[test-suite] constructs: huge loops, upvalue', function (t) {
- let luaCode = `
- -- sometimes will be 0, sometimes will not...
- _ENV.GLOB1 = math.floor(os.time()) % 2
-
- -- basic expressions with their respective values
- local basiccases = {
- {"nil", nil},
- {"false", false},
- {"true", true},
- {"10", 10},
- {"(0==_ENV.GLOB1)", 0 == _ENV.GLOB1},
- }
-
- print('testing short-circuit optimizations (' .. _ENV.GLOB1 .. ')')
-
-
- -- operators with their respective values
- local binops = {
- {" and ", function (a,b) if not a then return a else return b end end},
- {" or ", function (a,b) if a then return a else return b end end},
- }
-
- local cases = {}
-
- -- creates all combinations of '(cases[i] op cases[n-i])' plus
- -- 'not(cases[i] op cases[n-i])' (syntax + value)
- local function createcases (n)
- local res = {}
- for i = 1, n - 1 do
- for _, v1 in ipairs(cases[i]) do
- for _, v2 in ipairs(cases[n - i]) do
- for _, op in ipairs(binops) do
- local t = {
- "(" .. v1[1] .. op[1] .. v2[1] .. ")",
- op[2](v1[2], v2[2])
- }
- res[#res + 1] = t
- res[#res + 1] = {"not" .. t[1], not t[2]}
- end
- end
+test.skip('[test-suite] constructs: huge loops, upvalue', function (t) {
+ let luaCode = `
+ -- sometimes will be 0, sometimes will not...
+ _ENV.GLOB1 = math.floor(os.time()) % 2
+
+ -- basic expressions with their respective values
+ local basiccases = {
+ {"nil", nil},
+ {"false", false},
+ {"true", true},
+ {"10", 10},
+ {"(0==_ENV.GLOB1)", 0 == _ENV.GLOB1},
+ }
+
+ print('testing short-circuit optimizations (' .. _ENV.GLOB1 .. ')')
+
+
+ -- operators with their respective values
+ local binops = {
+ {" and ", function (a,b) if not a then return a else return b end end},
+ {" or ", function (a,b) if a then return a else return b end end},
+ }
+
+ local cases = {}
+
+ -- creates all combinations of '(cases[i] op cases[n-i])' plus
+ -- 'not(cases[i] op cases[n-i])' (syntax + value)
+ local function createcases (n)
+ local res = {}
+ for i = 1, n - 1 do
+ for _, v1 in ipairs(cases[i]) do
+ for _, v2 in ipairs(cases[n - i]) do
+ for _, op in ipairs(binops) do
+ local t = {
+ "(" .. v1[1] .. op[1] .. v2[1] .. ")",
+ op[2](v1[2], v2[2])
+ }
+ res[#res + 1] = t
+ res[#res + 1] = {"not" .. t[1], not t[2]}
end
end
- return res
end
+ end
+ return res
+ end
- -- do not do too many combinations for soft tests
- local level = _soft and 3 or 4
+ -- do not do too many combinations for soft tests
+ local level = _soft and 3 or 4
- cases[1] = basiccases
- for i = 2, level do cases[i] = createcases(i) end
+ cases[1] = basiccases
+ for i = 2, level do cases[i] = createcases(i) end
- local prog = [[if %s then IX = true end; return %s]]
+ local prog = [[if %s then IX = true end; return %s]]
- local i = 0
- for n = 1, level do
- for _, v in pairs(cases[n]) do
- local s = v[1]
- local p = load(string.format(prog, s, s), "")
- IX = false
- assert(p() == v[2] and IX == not not v[2])
- i = i + 1
- if i % 60000 == 0 then print('+') end
- end
- end
- `, L;
-
- t.plan(2);
+ local i = 0
+ for n = 1, level do
+ for _, v in pairs(cases[n]) do
+ local s = v[1]
+ local p = load(string.format(prog, s, s), "")
+ IX = false
+ assert(p() == v[2] and IX == not not v[2])
+ i = i + 1
+ if i % 60000 == 0 then print('+') end
+ end
+ end
+ `, L;
- t.doesNotThrow(function () {
+ t.plan(2);
+
+ t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
+ L = lauxlib.luaL_newstate();
- lualib.luaL_openlibs(L);
+ lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkload + luaCode));
+ lauxlib.luaL_loadstring(L, lua.to_luastring(checkload + luaCode));
- }, "Lua program loaded without error");
+ }, "Lua program loaded without error");
- t.doesNotThrow(function () {
+ t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
- }, "Lua program ran without error");
+ }, "Lua program ran without error");
- });
-}
+});
test("[test-suite] constructs: testing some syntax errors (chosen through 'gcov')", function (t) {
@@ -421,7 +419,7 @@ test("[test-suite] constructs: testing some syntax errors (chosen through 'gcov'
checkload(s, "too long")
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
diff --git a/tests/test-suite/db.js b/tests/test-suite/db.js
index 6d85a5f..a2e3ce6 100644
--- a/tests/test-suite/db.js
+++ b/tests/test-suite/db.js
@@ -515,7 +515,7 @@ test("[test-suite] db: tests for manipulating non-registered locals (C and Lua t
function g(a,b) return (a+1) + f() end
assert(g(0,0) == 30)
-
+
debug.sethook(nil);
assert(debug.gethook() == nil)
@@ -565,7 +565,7 @@ test("[test-suite] db: testing access to function arguments", function (t) {
dostring("XX = 12") -- test dostring inside hooks
-- testing errors inside hooks
assert(not pcall(load("a='joao'+1")))
- debug.sethook(function (e, l)
+ debug.sethook(function (e, l)
assert(debug.getinfo(2, "l").currentline == l)
local f,m,c = debug.gethook()
assert(e == "line")
@@ -690,7 +690,7 @@ test("[test-suite] db: testing upvalue access", function (t) {
assert(debug.setupvalue(foo1, 1, "xuxu") == "b")
assert(({debug.getupvalue(foo2, 3)})[2] == "xuxu")
-- upvalues of C functions are allways "called" "" (the empty string)
- assert(debug.getupvalue(string.gmatch("x", "x"), 1) == "")
+ assert(debug.getupvalue(string.gmatch("x", "x"), 1) == "")
`, L;
t.plan(2);
@@ -1030,7 +1030,7 @@ test("[test-suite] db: testing debugging of coroutines", function (t) {
let b = lua.to_luastring(luaCode);
if (lauxlib.luaL_loadbuffer(L, b, b.length, lua.to_luastring("@db.lua")) !== lua.LUA_OK)
- throw Error(lua.lua_tojsstring(L, -1));
+ throw Error(lua.lua_tojsstring(L, -1));
}, "Lua program loaded without error");
@@ -1304,7 +1304,7 @@ test("[test-suite] db: testing traceback sizes", function (t) {
let b = lua.to_luastring(luaCode);
if (lauxlib.luaL_loadbuffer(L, b, b.length, lua.to_luastring("@db.lua")) !== lua.LUA_OK)
- throw Error(lua.lua_tojsstring(L, -1));
+ throw Error(lua.lua_tojsstring(L, -1));
}, "Lua program loaded without error");
@@ -1389,7 +1389,7 @@ test("[test-suite] db: tests for 'source' in binary dumps", function (t) {
do
local prog = [[
return function (x)
- return function (y)
+ return function (y)
return x + y
end
end
@@ -1404,7 +1404,7 @@ test("[test-suite] db: tests for 'source' in binary dumps", function (t) {
local h = g(3)
assert(h(5) == 8)
assert(debug.getinfo(f).source == name and -- all functions have 'source'
- debug.getinfo(g).source == name and
+ debug.getinfo(g).source == name and
debug.getinfo(h).source == name)
-- again, without debug info
local c = string.dump(p, true)
@@ -1414,7 +1414,7 @@ test("[test-suite] db: tests for 'source' in binary dumps", function (t) {
local h = g(30)
assert(h(50) == 80)
assert(debug.getinfo(f).source == '=?' and -- no function has 'source'
- debug.getinfo(g).source == '=?' and
+ debug.getinfo(g).source == '=?' and
debug.getinfo(h).source == '=?')
end
`, L;
diff --git a/tests/test-suite/ltests.js b/tests/test-suite/ltests.js
index 67ab87d..8d89102 100644
--- a/tests/test-suite/ltests.js
+++ b/tests/test-suite/ltests.js
@@ -58,7 +58,7 @@ const getstring = function(L, buff, pc) {
pc.offset++;
} else {
while (pc.script[pc.offset] !== 0 && pc.offset < pc.script.length && delimits.indexOf(pc.script[pc.offset]) < 0)
- buff[i++] = pc.script[pc.offset++];
+ buff[i++] = pc.script[pc.offset++];
}
buff.length = i;
return buff;
@@ -107,379 +107,378 @@ const runJS = function(L, L1, pc) {
let inst = lua.to_jsstring(getstring(L, buff, pc));
if (inst.length === 0) return 0;
switch (inst) {
- case "absindex": {
- lua.lua_pushnumber(L1, lua.lua_absindex(L1, getindex(L, L1, pc)));
- break;
- }
- case "append": {
- let t = getindex(L, L1, pc);
- let i = lua.lua_rawlen(L1, t);
- lua.lua_rawseti(L1, t, i + 1);
- break;
- }
- case "arith": {
- let op;
- skip(pc);
- op = ops.indexOf(pc.script[pc.offset++]);
- lua.lua_arith(L1, op);
- break;
- }
- case "call": {
- let narg = getnum(L, L1, pc);
- let nres = getnum(L, L1, pc);
- lua.lua_call(L1, narg, nres);
- break;
- }
- case "callk": {
- let narg = getnum(L, L1, pc);
- let nres = getnum(L, L1, pc);
- let i = getindex(L, L1, pc);
- lua.lua_callk(L1, narg, nres, i, Cfunck);
- break;
- }
- case "checkstack": {
- let sz = getnum(L, L1, pc);
- let msg = getstring(L, buff, pc);
- if (msg.length === 0)
- msg = null; /* to test 'luaL_checkstack' with no message */
- lauxlib.luaL_checkstack(L1, sz, msg);
- break;
- }
- case "compare": {
- let opt = getstring(L, buff, pc); /* EQ, LT, or LE */
- let op = (opt[0] === 'E'.charCodeAt(0)) ? lua.LUA_OPEQ
- : (opt[1] === 'T'.charCodeAt(0)) ? lua.LUA_OPLT : lua.LUA_OPLE;
- let a = getindex(L, L1, pc);
- let b = getindex(L, L1, pc);
- lua.lua_pushboolean(L1, lua.lua_compare(L1, a, b, op));
- break;
- }
- case "concat": {
- lua.lua_concat(L1, getnum(L, L1, pc));
- break;
- }
- case "copy": {
- let f = getindex(L, L1, pc);
- lua.lua_copy(L1, f, getindex(L, L1, pc));
- break;
- }
- case "func2num": {
- let func = lua.lua_tocfunction(L1, getindex(L, L1, pc));
- if (func === null) func = 0;
- else if (func.id) func = func.id;
- lua.lua_pushnumber(L1, func);
- break;
- }
- case "getfield": {
- let t = getindex(L, L1, pc);
- lua.lua_getfield(L1, t, getstring(L, buff, pc));
- break;
- }
- case "getglobal": {
- lua.lua_getglobal(L1, getstring(L, buff, pc));
- break;
- }
- case "getmetatable": {
- if (lua.lua_getmetatable(L1, getindex(L, L1, pc)) === 0)
+ case "absindex": {
+ lua.lua_pushnumber(L1, lua.lua_absindex(L1, getindex(L, L1, pc)));
+ break;
+ }
+ case "append": {
+ let t = getindex(L, L1, pc);
+ let i = lua.lua_rawlen(L1, t);
+ lua.lua_rawseti(L1, t, i + 1);
+ break;
+ }
+ case "arith": {
+ let op;
+ skip(pc);
+ op = ops.indexOf(pc.script[pc.offset++]);
+ lua.lua_arith(L1, op);
+ break;
+ }
+ case "call": {
+ let narg = getnum(L, L1, pc);
+ let nres = getnum(L, L1, pc);
+ lua.lua_call(L1, narg, nres);
+ break;
+ }
+ case "callk": {
+ let narg = getnum(L, L1, pc);
+ let nres = getnum(L, L1, pc);
+ let i = getindex(L, L1, pc);
+ lua.lua_callk(L1, narg, nres, i, Cfunck);
+ break;
+ }
+ case "checkstack": {
+ let sz = getnum(L, L1, pc);
+ let msg = getstring(L, buff, pc);
+ if (msg.length === 0)
+ msg = null; /* to test 'luaL_checkstack' with no message */
+ lauxlib.luaL_checkstack(L1, sz, msg);
+ break;
+ }
+ case "compare": {
+ let opt = getstring(L, buff, pc); /* EQ, LT, or LE */
+ let op = (opt[0] === 'E'.charCodeAt(0))
+ ? lua.LUA_OPEQ
+ : (opt[1] === 'T'.charCodeAt(0)) ? lua.LUA_OPLT : lua.LUA_OPLE;
+ let a = getindex(L, L1, pc);
+ let b = getindex(L, L1, pc);
+ lua.lua_pushboolean(L1, lua.lua_compare(L1, a, b, op));
+ break;
+ }
+ case "concat": {
+ lua.lua_concat(L1, getnum(L, L1, pc));
+ break;
+ }
+ case "copy": {
+ let f = getindex(L, L1, pc);
+ lua.lua_copy(L1, f, getindex(L, L1, pc));
+ break;
+ }
+ case "func2num": {
+ let func = lua.lua_tocfunction(L1, getindex(L, L1, pc));
+ if (func === null) func = 0;
+ else if (func.id) func = func.id;
+ lua.lua_pushnumber(L1, func);
+ break;
+ }
+ case "getfield": {
+ let t = getindex(L, L1, pc);
+ lua.lua_getfield(L1, t, getstring(L, buff, pc));
+ break;
+ }
+ case "getglobal": {
+ lua.lua_getglobal(L1, getstring(L, buff, pc));
+ break;
+ }
+ case "getmetatable": {
+ if (lua.lua_getmetatable(L1, getindex(L, L1, pc)) === 0)
+ lua.lua_pushnil(L1);
+ break;
+ }
+ case "gettable": {
+ lua.lua_gettable(L1, getindex(L, L1, pc));
+ break;
+ }
+ case "gettop": {
+ lua.lua_pushinteger(L1, lua.lua_gettop(L1));
+ break;
+ }
+ case "gsub": {
+ let a = getnum(L, L1, pc);
+ let b = getnum(L, L1, pc);
+ let c = getnum(L, L1, pc);
+ lauxlib.luaL_gsub(L1, lua.lua_tostring(L1, a), lua.lua_tostring(L1, b), lua.lua_tostring(L1, c));
+ break;
+ }
+ case "insert": {
+ lua.lua_insert(L1, getnum(L, L1, pc));
+ break;
+ }
+ case "iscfunction": {
+ lua.lua_pushboolean(L1, lua.lua_iscfunction(L1, getindex(L, L1, pc)));
+ break;
+ }
+ case "isfunction": {
+ lua.lua_pushboolean(L1, lua.lua_isfunction(L1, getindex(L, L1, pc)));
+ break;
+ }
+ case "isnil": {
+ lua.lua_pushboolean(L1, lua.lua_isnil(L1, getindex(L, L1, pc)));
+ break;
+ }
+ case "isnull": {
+ lua.lua_pushboolean(L1, lua.lua_isnone(L1, getindex(L, L1, pc)));
+ break;
+ }
+ case "isnumber": {
+ lua.lua_pushboolean(L1, lua.lua_isnumber(L1, getindex(L, L1, pc)));
+ break;
+ }
+ case "isstring": {
+ lua.lua_pushboolean(L1, lua.lua_isstring(L1, getindex(L, L1, pc)));
+ break;
+ }
+ case "istable": {
+ lua.lua_pushboolean(L1, lua.lua_istable(L1, getindex(L, L1, pc)));
+ break;
+ }
+ case "isudataval": {
+ lua.lua_pushboolean(L1, lua.lua_islightuserdata(L1, getindex(L, L1, pc)));
+ break;
+ }
+ case "isuserdata": {
+ lua.lua_pushboolean(L1, lua.lua_isuserdata(L1, getindex(L, L1, pc)));
+ break;
+ }
+ case "len": {
+ lua.lua_len(L1, getindex(L, L1, pc));
+ break;
+ }
+ case "Llen": {
+ lua.lua_pushinteger(L1, lauxlib.luaL_len(L1, getindex(L, L1, pc)));
+ break;
+ }
+ case "loadfile": {
+ lauxlib.luaL_loadfile(L1, lauxlib.luaL_checkstring(L1, getnum(L, L1, pc)));
+ break;
+ }
+ case "loadstring": {
+ let s = lauxlib.luaL_checkstring(L1, getnum(L, L1, pc));
+ lauxlib.luaL_loadstring(L1, s);
+ break;
+ }
+ case "newmetatable": {
+ lua.lua_pushboolean(L1, lauxlib.luaL_newmetatable(L1, getstring(L, buff, pc)));
+ break;
+ }
+ case "newtable": {
+ lua.lua_newtable(L1);
+ break;
+ }
+ case "newthread": {
+ lua.lua_newthread(L1);
+ break;
+ }
+ case "newuserdata": {
+ lua.lua_newuserdata(L1, getnum(L, L1, pc));
+ break;
+ }
+ case "next": {
+ lua.lua_next(L1, -2);
+ break;
+ }
+ case "objsize": {
+ lua.lua_pushinteger(L1, lua.lua_rawlen(L1, getindex(L, L1, pc)));
+ break;
+ }
+ case "pcall": {
+ let narg = getnum(L, L1, pc);
+ let nres = getnum(L, L1, pc);
+ status = lua.lua_pcall(L1, narg, nres, getnum(L, L1, pc));
+ break;
+ }
+ case "pcallk": {
+ let narg = getnum(L, L1, pc);
+ let nres = getnum(L, L1, pc);
+ let i = getindex(L, L1, pc);
+ status = lua.lua_pcallk(L1, narg, nres, 0, i, Cfunck);
+ break;
+ }
+ case "pop": {
+ lua.lua_pop(L1, getnum(L, L1, pc));
+ break;
+ }
+ case "print": {
+ let n = getnum(L, L1, pc);
+ if (n !== 0) {
+ console.log(`${lauxlib.luaL_tojsstring(L1, n, null)}\n`);
+ lua.lua_pop(L1, 1);
+ }
+ else printstack(L1);
+ break;
+ }
+ case "pushbool": {
+ lua.lua_pushboolean(L1, getnum(L, L1, pc));
+ break;
+ }
+ case "pushcclosure": {
+ lua.lua_pushcclosure(L1, testJS, getnum(L, L1, pc));
+ break;
+ }
+ case "pushint": {
+ lua.lua_pushinteger(L1, getnum(L, L1, pc));
+ break;
+ }
+ case "pushnil": {
lua.lua_pushnil(L1);
- break;
- }
- case "gettable": {
- lua.lua_gettable(L1, getindex(L, L1, pc));
- break;
- }
- case "gettop": {
- lua.lua_pushinteger(L1, lua.lua_gettop(L1));
- break;
- }
- case "gsub": {
- let a = getnum(L, L1, pc);
- let b = getnum(L, L1, pc);
- let c = getnum(L, L1, pc);
- lauxlib.luaL_gsub(L1, lua.lua_tostring(L1, a), lua.lua_tostring(L1, b), lua.lua_tostring(L1, c));
- break;
- }
- case "insert": {
- lua.lua_insert(L1, getnum(L, L1, pc));
- break;
- }
- case "iscfunction": {
- lua.lua_pushboolean(L1, lua.lua_iscfunction(L1, getindex(L, L1, pc)));
- break;
- }
- case "isfunction": {
- lua.lua_pushboolean(L1, lua.lua_isfunction(L1, getindex(L, L1, pc)));
- break;
- }
- case "isnil": {
- lua.lua_pushboolean(L1, lua.lua_isnil(L1, getindex(L, L1, pc)));
- break;
- }
- case "isnull": {
- lua.lua_pushboolean(L1, lua.lua_isnone(L1, getindex(L, L1, pc)));
- break;
- }
- case "isnumber": {
- lua.lua_pushboolean(L1, lua.lua_isnumber(L1, getindex(L, L1, pc)));
- break;
- }
- case "isstring": {
- lua.lua_pushboolean(L1, lua.lua_isstring(L1, getindex(L, L1, pc)));
- break;
- }
- case "istable": {
- lua.lua_pushboolean(L1, lua.lua_istable(L1, getindex(L, L1, pc)));
- break;
- }
- case "isudataval": {
- lua.lua_pushboolean(L1, lua.lua_islightuserdata(L1, getindex(L, L1, pc)));
- break;
- }
- case "isuserdata": {
- lua.lua_pushboolean(L1, lua.lua_isuserdata(L1, getindex(L, L1, pc)));
- break;
- }
- case "len": {
- lua.lua_len(L1, getindex(L, L1, pc));
- break;
- }
- case "Llen": {
- lua.lua_pushinteger(L1, lauxlib.luaL_len(L1, getindex(L, L1, pc)));
- break;
- }
- case "loadfile": {
- lauxlib.luaL_loadfile(L1, lauxlib.luaL_checkstring(L1, getnum(L, L1, pc)));
- break;
- }
- case "loadstring": {
- let s = lauxlib.luaL_checkstring(L1, getnum(L, L1, pc));
- lauxlib.luaL_loadstring(L1, s);
- break;
- }
- case "newmetatable": {
- lua.lua_pushboolean(L1, lauxlib.luaL_newmetatable(L1, getstring(L, buff, pc)));
- break;
- }
- case "newtable": {
- lua.lua_newtable(L1);
- break;
- }
- case "newthread": {
- lua.lua_newthread(L1);
- break;
- }
- case "newuserdata": {
- lua.lua_newuserdata(L1, getnum(L, L1, pc));
- break;
- }
- case "next": {
- lua.lua_next(L1, -2);
- break;
- }
- case "objsize": {
- lua.lua_pushinteger(L1, lua.lua_rawlen(L1, getindex(L, L1, pc)));
- break;
- }
- case "pcall": {
- let narg = getnum(L, L1, pc);
- let nres = getnum(L, L1, pc);
- status = lua.lua_pcall(L1, narg, nres, getnum(L, L1, pc));
- break;
- }
- case "pcallk": {
- let narg = getnum(L, L1, pc);
- let nres = getnum(L, L1, pc);
- let i = getindex(L, L1, pc);
- status = lua.lua_pcallk(L1, narg, nres, 0, i, Cfunck);
- break;
- }
- case "pop": {
- lua.lua_pop(L1, getnum(L, L1, pc));
- break;
- }
- case "print": {
- let n = getnum(L, L1, pc);
- if (n !== 0) {
- console.log(`${lauxlib.luaL_tojsstring(L1, n, null)}\n`);
- lua.lua_pop(L1, 1);
+ break;
}
- else printstack(L1);
- break;
- }
- case "pushbool": {
- lua.lua_pushboolean(L1, getnum(L, L1, pc));
- break;
- }
- case "pushcclosure": {
- lua.lua_pushcclosure(L1, testJS, getnum(L, L1, pc));
- break;
- }
- case "pushint": {
- lua.lua_pushinteger(L1, getnum(L, L1, pc));
- break;
- }
- case "pushnil": {
- lua.lua_pushnil(L1);
- break;
- }
- case "pushnum": {
- lua.lua_pushnumber(L1, getnum(L, L1, pc));
- break;
- }
- case "pushstatus": {
- pushcode(L1, status);
- break;
- }
- case "pushstring": {
- lua.lua_pushstring(L1, getstring(L, buff, pc));
- break;
- }
- case "pushupvalueindex": {
- lua.lua_pushinteger(L1, lua.lua_upvalueindex(getnum(L, L1, pc)));
- break;
- }
- case "pushvalue": {
- lua.lua_pushvalue(L1, getindex(L, L1, pc));
- break;
- }
- case "rawgeti": {
- let t = getindex(L, L1, pc);
- lua.lua_rawgeti(L1, t, getnum(L, L1, pc));
- break;
- }
- case "rawgetp": {
- let t = getindex(L, L1, pc);
- lua.lua_rawgetp(L1, t, getnum(L, L1, pc));
- break;
- }
- case "rawsetp": {
- let t = getindex(L, L1, pc);
- lua.lua_rawsetp(L1, t, getnum(L, L1, pc));
- break;
- }
- case "remove": {
- lua.lua_remove(L1, getnum(L, L1, pc));
- break;
- }
- case "replace": {
- lua.lua_replace(L1, getindex(L, L1, pc));
- break;
- }
- case "resume": {
- let i = getindex(L, L1, pc);
- status = lua.lua_resume(lua.lua_tothread(L1, i), L, getnum(L, L1, pc));
- break;
- }
- case "return": {
- let n = getnum(L, L1, pc);
- if (L1 != L) {
- let i;
- for (i = 0; i < n; i++)
- lua.lua_pushstring(L, lua.lua_tostring(L1, -(n - i)));
- }
- return n;
- }
- case "rotate": {
- let i = getindex(L, L1, pc);
- lua.lua_rotate(L1, i, getnum(L, L1, pc));
- break;
- }
- case "setfield": {
- let t = getindex(L, L1, pc);
- lua.lua_setfield(L1, t, getstring(L, buff, pc));
- break;
- }
- case "setglobal": {
- lua.lua_setglobal(L1, getstring(L, buff, pc));
- break;
- }
- case "sethook": {
- let mask = getnum(L, L1, pc);
- let count = getnum(L, L1, pc);
- sethookaux(L1, mask, count, getstring(L, buff, pc));
- break;
- }
- case "setmetatable": {
- lua.lua_setmetatable(L1, getindex(L, L1, pc));
- break;
- }
- case "settable": {
- lua.lua_settable(L1, getindex(L, L1, pc));
- break;
- }
- case "settop": {
- lua.lua_settop(L1, getnum(L, L1, pc));
- break;
- }
- case "testudata": {
- let i = getindex(L, L1, pc);
- lua.lua_pushboolean(L1, lauxlib.luaL_testudata(L1, i, getstring(L, buff, pc)) !== null);
- break;
- }
- case "error": {
- lua.lua_error(L1);
- break;
- }
- case "throw": {
- throw new Error();
- break;
- }
- case "tobool": {
- lua.lua_pushboolean(L1, lua.lua_toboolean(L1, getindex(L, L1, pc)));
- break;
- }
- case "tocfunction": {
- lua.lua_pushcfunction(L1, lua.lua_tocfunction(L1, getindex(L, L1, pc)));
- break;
- }
- case "tointeger": {
- lua.lua_pushinteger(L1, lua.lua_tointeger(L1, getindex(L, L1, pc)));
- break;
- }
- case "tonumber": {
- lua.lua_pushnumber(L1, lua.lua_tonumber(L1, getindex(L, L1, pc)));
- break;
- }
- case "topointer": {
- let p = lua.lua_topointer(L1, getindex(L, L1, pc));
- if (p === null) p = 0;
- else if (p.id) p = p.id;
- lua.lua_pushnumber(L1, p); /* in ltests.c, p is casted to a size_t so NULL gives 0 */
- break;
- }
- case "tostring": {
- let s = lua.lua_tostring(L1, getindex(L, L1, pc));
- let s1 = lua.lua_pushstring(L1, s);
- assert((s === null && s1 === null) || s.join('|') === s1.join('|'));
- break;
- }
- case "type": {
- lua.lua_pushstring(L1, lauxlib.luaL_typename(L1, getnum(L, L1, pc)));
- break;
- }
- case "xmove": {
- let f = getindex(L, L1, pc);
- let t = getindex(L, L1, pc);
- let fs = (f === 0) ? L1 : lua.lua_tothread(L1, f);
- let ts = (t === 0) ? L1 : lua.lua_tothread(L1, t);
- let n = getnum(L, L1, pc);
- if (n === 0) n = lua.lua_gettop(fs);
- lua.lua_xmove(fs, ts, n);
- break;
- }
- case "yield": {
- return lua.lua_yield(L1, getnum(L, L1, pc));
- }
- case "yieldk": {
- let nres = getnum(L, L1, pc);
- let i = getindex(L, L1, pc);
- return lua.lua_yieldk(L1, nres, i, Cfunck);
- }
- default:
- lauxlib.luaL_error(L, lua.to_luastring("unknown instruction %s"), buff);
+ case "pushnum": {
+ lua.lua_pushnumber(L1, getnum(L, L1, pc));
+ break;
+ }
+ case "pushstatus": {
+ pushcode(L1, status);
+ break;
+ }
+ case "pushstring": {
+ lua.lua_pushstring(L1, getstring(L, buff, pc));
+ break;
+ }
+ case "pushupvalueindex": {
+ lua.lua_pushinteger(L1, lua.lua_upvalueindex(getnum(L, L1, pc)));
+ break;
+ }
+ case "pushvalue": {
+ lua.lua_pushvalue(L1, getindex(L, L1, pc));
+ break;
+ }
+ case "rawgeti": {
+ let t = getindex(L, L1, pc);
+ lua.lua_rawgeti(L1, t, getnum(L, L1, pc));
+ break;
+ }
+ case "rawgetp": {
+ let t = getindex(L, L1, pc);
+ lua.lua_rawgetp(L1, t, getnum(L, L1, pc));
+ break;
+ }
+ case "rawsetp": {
+ let t = getindex(L, L1, pc);
+ lua.lua_rawsetp(L1, t, getnum(L, L1, pc));
+ break;
+ }
+ case "remove": {
+ lua.lua_remove(L1, getnum(L, L1, pc));
+ break;
+ }
+ case "replace": {
+ lua.lua_replace(L1, getindex(L, L1, pc));
+ break;
+ }
+ case "resume": {
+ let i = getindex(L, L1, pc);
+ status = lua.lua_resume(lua.lua_tothread(L1, i), L, getnum(L, L1, pc));
+ break;
+ }
+ case "return": {
+ let n = getnum(L, L1, pc);
+ if (L1 != L) {
+ let i;
+ for (i = 0; i < n; i++)
+ lua.lua_pushstring(L, lua.lua_tostring(L1, -(n - i)));
+ }
+ return n;
+ }
+ case "rotate": {
+ let i = getindex(L, L1, pc);
+ lua.lua_rotate(L1, i, getnum(L, L1, pc));
+ break;
+ }
+ case "setfield": {
+ let t = getindex(L, L1, pc);
+ lua.lua_setfield(L1, t, getstring(L, buff, pc));
+ break;
+ }
+ case "setglobal": {
+ lua.lua_setglobal(L1, getstring(L, buff, pc));
+ break;
+ }
+ case "sethook": {
+ let mask = getnum(L, L1, pc);
+ let count = getnum(L, L1, pc);
+ sethookaux(L1, mask, count, getstring(L, buff, pc));
+ break;
+ }
+ case "setmetatable": {
+ lua.lua_setmetatable(L1, getindex(L, L1, pc));
+ break;
+ }
+ case "settable": {
+ lua.lua_settable(L1, getindex(L, L1, pc));
+ break;
+ }
+ case "settop": {
+ lua.lua_settop(L1, getnum(L, L1, pc));
+ break;
+ }
+ case "testudata": {
+ let i = getindex(L, L1, pc);
+ lua.lua_pushboolean(L1, lauxlib.luaL_testudata(L1, i, getstring(L, buff, pc)) !== null);
+ break;
+ }
+ case "error": {
+ lua.lua_error(L1);
+ break;
+ }
+ case "throw": {
+ throw new Error();
+ }
+ case "tobool": {
+ lua.lua_pushboolean(L1, lua.lua_toboolean(L1, getindex(L, L1, pc)));
+ break;
+ }
+ case "tocfunction": {
+ lua.lua_pushcfunction(L1, lua.lua_tocfunction(L1, getindex(L, L1, pc)));
+ break;
+ }
+ case "tointeger": {
+ lua.lua_pushinteger(L1, lua.lua_tointeger(L1, getindex(L, L1, pc)));
+ break;
+ }
+ case "tonumber": {
+ lua.lua_pushnumber(L1, lua.lua_tonumber(L1, getindex(L, L1, pc)));
+ break;
+ }
+ case "topointer": {
+ let p = lua.lua_topointer(L1, getindex(L, L1, pc));
+ if (p === null) p = 0;
+ else if (p.id) p = p.id;
+ lua.lua_pushnumber(L1, p); /* in ltests.c, p is casted to a size_t so NULL gives 0 */
+ break;
+ }
+ case "tostring": {
+ let s = lua.lua_tostring(L1, getindex(L, L1, pc));
+ let s1 = lua.lua_pushstring(L1, s);
+ assert((s === null && s1 === null) || s.join('|') === s1.join('|'));
+ break;
+ }
+ case "type": {
+ lua.lua_pushstring(L1, lauxlib.luaL_typename(L1, getnum(L, L1, pc)));
+ break;
+ }
+ case "xmove": {
+ let f = getindex(L, L1, pc);
+ let t = getindex(L, L1, pc);
+ let fs = (f === 0) ? L1 : lua.lua_tothread(L1, f);
+ let ts = (t === 0) ? L1 : lua.lua_tothread(L1, t);
+ let n = getnum(L, L1, pc);
+ if (n === 0) n = lua.lua_gettop(fs);
+ lua.lua_xmove(fs, ts, n);
+ break;
+ }
+ case "yield": {
+ return lua.lua_yield(L1, getnum(L, L1, pc));
+ }
+ case "yieldk": {
+ let nres = getnum(L, L1, pc);
+ let i = getindex(L, L1, pc);
+ return lua.lua_yieldk(L1, nres, i, Cfunck);
+ }
+ default:
+ lauxlib.luaL_error(L, lua.to_luastring("unknown instruction %s"), buff);
}
- }
- return 0;
+ }
};
@@ -817,7 +816,7 @@ const buildop = function(p, pc) {
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, lua.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);
diff --git a/tests/test-suite/strings.js b/tests/test-suite/strings.js
index 50873e5..0efedcb 100644
--- a/tests/test-suite/strings.js
+++ b/tests/test-suite/strings.js
@@ -36,7 +36,7 @@ test('[test-suite] strings: string comparisons', function (t) {
assert('\\0\\0\\0' >= '\\0\\0\\0')
assert(not ('\\0\\0b' < '\\0\\0a\\0'))
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -78,7 +78,7 @@ test('[test-suite] strings: string.sub', function (t) {
assert('\\0\\0\\0' >= '\\0\\0\\0')
assert(not ('\\0\\0b' < '\\0\\0a\\0'))
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -116,7 +116,7 @@ test('[test-suite] strings: string.find', function (t) {
assert(string.find('', 'aaa', 1) == nil)
assert(('alo(.)alo'):find('(.)', 1, 1) == 4)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -148,7 +148,7 @@ test('[test-suite] strings: string.len and #', function (t) {
assert(#"\\0\\0\\0" == 3)
assert(#"1234567890" == 10)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -205,7 +205,7 @@ test('[test-suite] strings: string.byte/string.char', function (t) {
checkerror("too large", string.rep, 'a', (1 << 30), ',')
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -242,7 +242,7 @@ test('[test-suite] strings: repetitions with separator', function (t) {
for i=0,30 do assert(string.len(string.rep('a', i)) == i) end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -294,7 +294,7 @@ test('[test-suite] strings: tostring', function (t) {
assert(tostring(-1203 + 0.0) == "-1203")
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -341,7 +341,7 @@ test('[test-suite] strings: string.format', function (t) {
assert(string.format('"-%20s.20s"', string.rep("%", 2000)) ==
string.format("%q", "-"..string.rep("%", 2000)..".20s"))
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -382,7 +382,7 @@ test('[test-suite] strings: %q', function (t) {
checkerror("no literal", string.format, "%q", {})
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -409,7 +409,7 @@ test('[test-suite] strings: embedded zeros error', function (t) {
assert(string.format("\\0%s\\0", "\\0\\0\\1") == "\\0\\0\\0\\1\\0")
checkerror("contains zeros", string.format, "%10s", "\\0")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -452,7 +452,7 @@ test('[test-suite] strings: format x tostring', function (t) {
assert(string.format("%+08d", 31501) == "+0031501")
assert(string.format("%+08d", -30927) == "-0030927")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -489,7 +489,7 @@ test('[test-suite] strings: longest number that can be formatted', function (t)
assert(tonumber(s) == -(10^i))
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -538,7 +538,7 @@ test('[test-suite] strings: large numbers for format', function (t) {
end
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -586,7 +586,7 @@ test("[test-suite] strings: 'format %a %A'", function (t) {
assert(string.find(string.format("%a", 0/0), "^%-?nan"))
assert(string.find(string.format("%a", -0.0), "^%-0x0"))
end
-
+
if not pcall(string.format, "%.3a", 0) then
(Message or print)("\\n >>> modifiers for format '%a' not available <<<\\n")
else
@@ -595,7 +595,7 @@ test("[test-suite] strings: 'format %a %A'", function (t) {
end
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -635,7 +635,7 @@ test("[test-suite] strings: errors in format", function (t) {
assert(load("return 1\\n--comment without ending EOL")() == 1)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -686,7 +686,7 @@ test("[test-suite] strings: table.concat", function (t) {
assert(table.concat(a, ",", 3) == "c")
assert(table.concat(a, ",", 4) == "")
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -709,61 +709,59 @@ test("[test-suite] strings: table.concat", function (t) {
// TODO: os.setlocale NYI
-if (false) {
- test("[test-suite] strings: locale", function (t) {
- let luaCode = `
- if not _port then
-
- local locales = { "ptb", "pt_BR.iso88591", "ISO-8859-1" }
- local function trylocale (w)
- for i = 1, #locales do
- if os.setlocale(locales[i], w) then
- print(string.format("'%s' locale set to '%s'", w, locales[i]))
- return locales[i]
- end
- end
- print(string.format("'%s' locale not found", w))
- return false
+test.skip("[test-suite] strings: locale", function (t) {
+ let luaCode = `
+ if not _port then
+
+ local locales = { "ptb", "pt_BR.iso88591", "ISO-8859-1" }
+ local function trylocale (w)
+ for i = 1, #locales do
+ if os.setlocale(locales[i], w) then
+ print(string.format("'%s' locale set to '%s'", w, locales[i]))
+ return locales[i]
end
+ end
+ print(string.format("'%s' locale not found", w))
+ return false
+ end
- if trylocale("collate") then
- assert("alo" < "álo" and "álo" < "amo")
- end
+ if trylocale("collate") then
+ assert("alo" < "álo" and "álo" < "amo")
+ end
- if trylocale("ctype") then
- assert(string.gsub("áéíóú", "%a", "x") == "xxxxx")
- assert(string.gsub("áÁéÉ", "%l", "x") == "xÁxÉ")
- assert(string.gsub("áÁéÉ", "%u", "x") == "áxéx")
- assert(string.upper"áÁé{xuxu}ção" == "ÁÁÉ{XUXU}ÇÃO")
- end
+ if trylocale("ctype") then
+ assert(string.gsub("áéíóú", "%a", "x") == "xxxxx")
+ assert(string.gsub("áÁéÉ", "%l", "x") == "xÁxÉ")
+ assert(string.gsub("áÁéÉ", "%u", "x") == "áxéx")
+ assert(string.upper"áÁé{xuxu}ção" == "ÁÁÉ{XUXU}ÇÃO")
+ end
- os.setlocale("C")
- assert(os.setlocale() == 'C')
- assert(os.setlocale(nil, "numeric") == 'C')
+ os.setlocale("C")
+ assert(os.setlocale() == 'C')
+ assert(os.setlocale(nil, "numeric") == 'C')
- end
- `, L;
-
- t.plan(2);
+ end
+ `, L;
- t.doesNotThrow(function () {
+ t.plan(2);
- L = lauxlib.luaL_newstate();
+ t.doesNotThrow(function () {
- lualib.luaL_openlibs(L);
+ L = lauxlib.luaL_newstate();
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkerror + luaCode));
+ lualib.luaL_openlibs(L);
- }, "Lua program loaded without error");
+ lauxlib.luaL_loadstring(L, lua.to_luastring(checkerror + luaCode));
- t.doesNotThrow(function () {
+ }, "Lua program loaded without error");
- lua.lua_call(L, 0, -1);
+ t.doesNotThrow(function () {
- }, "Lua program ran without error");
+ lua.lua_call(L, 0, -1);
- });
-}
+ }, "Lua program ran without error");
+
+});
test("[test-suite] strings: bug in Lua 5.3.2: 'gmatch' iterator does not work across coroutines", function (t) {
@@ -775,7 +773,7 @@ test("[test-suite] strings: bug in Lua 5.3.2: 'gmatch' iterator does not work ac
assert(co() == "2")
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
diff --git a/tests/tests.js b/tests/tests.js
index b70a306..1bc4fc6 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -7,9 +7,9 @@ const toByteCode = function(luaCode) {
let L = getState(luaCode);
let b = [];
if (lua.lua_dump(L, function(L, b, size, B) {
- B.push(...b.slice(0, size));
- return 0;
- }, b, false) !== 0)
+ B.push(...b.slice(0, size));
+ return 0;
+ }, b, false) !== 0)
throw Error("unable to dump given function");
return new DataView(Uint8Array.from(b).buffer);
};