aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2018-04-20 21:16:24 +1000
committerdaurnimator <quae@daurnimator.com>2018-04-20 21:16:24 +1000
commita260f381d30e036b39078fee0295e539067c10a3 (patch)
tree4f3b2ecb264ec8dd29cac74d23223d15d297eb8e
parentfe9b43374c2e8dc28df0ce460aefaf50b933aaa7 (diff)
parent9f5d4d35de0b88334bba7c11a9e960a19ee0740b (diff)
downloadfengari-a260f381d30e036b39078fee0295e539067c10a3.tar.gz
fengari-a260f381d30e036b39078fee0295e539067c10a3.tar.bz2
fengari-a260f381d30e036b39078fee0295e539067c10a3.zip
Merge branch 'test-with-jest'
-rw-r--r--.travis.yml2
-rw-r--r--package.json21
-rw-r--r--test/defs.test.js94
-rw-r--r--test/lapi.test.js382
-rw-r--r--test/lauxlib.test.js (renamed from tests/lauxlib.js)23
-rw-r--r--test/lbaselib.test.js435
-rw-r--r--test/lcorolib.test.js143
-rw-r--r--test/ldblib.test.js310
-rw-r--r--test/ldebug.test.js135
-rw-r--r--test/lexparse.test.js (renamed from tests/lexparse.js)853
-rw-r--r--test/lib-hello.js.mod (renamed from tests/lib-hello.js.mod)0
-rw-r--r--test/lmathlib.test.js251
-rw-r--r--test/load.test.js115
-rw-r--r--test/loadfile-test.bc (renamed from tests/loadfile-test.bc)bin138 -> 138 bytes
-rw-r--r--test/loadfile-test.lua (renamed from tests/loadfile-test.lua)0
-rw-r--r--test/loadlib.test.js73
-rw-r--r--test/loslib.test.js101
-rw-r--r--test/lstrlib.test.js433
-rw-r--r--test/ltablib.test.js183
-rw-r--r--test/ltm.test.js559
-rw-r--r--test/lua.test.js55
-rw-r--r--test/lutf8lib.test.js97
-rw-r--r--test/lvm.test.js (renamed from tests/lvm.js)670
-rwxr-xr-xtest/manual-tests/debug-cli.js (renamed from tests/manual-tests/debug-cli.js)0
-rw-r--r--test/module-hello.lua (renamed from tests/module-hello.lua)0
-rw-r--r--test/test-suite/api.test.js (renamed from tests/test-suite/api.js)1546
-rw-r--r--test/test-suite/attrib.test.js (renamed from tests/test-suite/attrib.js)193
-rw-r--r--test/test-suite/bitwise.test.js (renamed from tests/test-suite/bitwise.js)246
-rw-r--r--test/test-suite/calls.test.js (renamed from tests/test-suite/calls.js)486
-rw-r--r--test/test-suite/closure.test.js (renamed from tests/test-suite/closure.js)246
-rw-r--r--test/test-suite/code.test.js (renamed from tests/test-suite/code.js)459
-rw-r--r--test/test-suite/constructs.test.js (renamed from tests/test-suite/constructs.js)188
-rw-r--r--test/test-suite/coroutine.test.js (renamed from tests/test-suite/coroutine.js)1118
-rw-r--r--test/test-suite/db.test.js (renamed from tests/test-suite/db.js)825
-rw-r--r--test/test-suite/errors.test.js (renamed from tests/test-suite/errors.js)1056
-rw-r--r--test/test-suite/events.test.js (renamed from tests/test-suite/events.js)425
-rw-r--r--test/test-suite/goto.test.js (renamed from tests/test-suite/goto.js)186
-rw-r--r--test/test-suite/literals.test.js (renamed from tests/test-suite/literals.js)460
-rw-r--r--test/test-suite/locals.test.js (renamed from tests/test-suite/locals.js)156
-rw-r--r--test/test-suite/ltests.js (renamed from tests/test-suite/ltests.js)0
-rw-r--r--test/test-suite/math.test.js (renamed from tests/test-suite/math.js)1172
-rw-r--r--test/test-suite/nextvar.test.js (renamed from tests/test-suite/nextvar.js)756
-rw-r--r--test/test-suite/pm-classes.lua (renamed from tests/test-suite/pm-classes.lua)0
-rw-r--r--test/test-suite/pm-gsub.lua (renamed from tests/test-suite/pm-gsub.lua)0
-rw-r--r--test/test-suite/pm.test.js (renamed from tests/test-suite/pm.js)546
-rw-r--r--test/test-suite/sort.test.js (renamed from tests/test-suite/sort.js)372
-rw-r--r--test/test-suite/strings.test.js (renamed from tests/test-suite/strings.js)548
-rw-r--r--test/test-suite/tpack.test.js (renamed from tests/test-suite/tpack.js)502
-rw-r--r--test/test-suite/utf8.test.js (renamed from tests/test-suite/utf8.js)222
-rw-r--r--test/test-suite/vararg.test.js (renamed from tests/test-suite/vararg.js)128
-rw-r--r--test/tests.js (renamed from tests/tests.js)19
-rw-r--r--tests/defs.js89
-rw-r--r--tests/lapi.js544
-rw-r--r--tests/lbaselib.js651
-rw-r--r--tests/lcorolib.js201
-rw-r--r--tests/ldblib.js492
-rw-r--r--tests/ldebug.js194
-rw-r--r--tests/lmathlib.js448
-rw-r--r--tests/load.js203
-rw-r--r--tests/loadlib.js130
-rw-r--r--tests/loslib.js169
-rw-r--r--tests/lstrlib.js865
-rw-r--r--tests/ltablib.js268
-rw-r--r--tests/ltm.js732
-rw-r--r--tests/lua.js87
-rw-r--r--tests/lutf8lib.js179
-rw-r--r--yarn.lock2800
67 files changed, 10305 insertions, 14537 deletions
diff --git a/.travis.yml b/.travis.yml
index 4e3940c..373ec4f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,7 +18,7 @@ before_install:
script:
- yarn lint
- - FENGARICONF='{"LUAI_MAXSTACK":100000}' travis_wait yarn test
+ - FENGARICONF='{"LUAI_MAXSTACK":100000}' yarn test --maxWorkers=$(nproc)
notifications:
email: false
diff --git a/package.json b/package.json
index bd75286..9988883 100644
--- a/package.json
+++ b/package.json
@@ -5,12 +5,12 @@
"main": "src/fengari.js",
"directories": {
"lib": "src",
- "test": "tests"
+ "test": "test"
},
"scripts": {
- "lint": "eslint src/ tests/",
+ "lint": "eslint src/ test/",
"prepublishOnly": "git diff-index --quiet --cached HEAD -- && npm run lint && npm run test",
- "test": "tape tests/*.js tests/test-suite/*.js | faucet"
+ "test": "jest"
},
"repository": {
"type": "git",
@@ -31,8 +31,7 @@
"homepage": "https://github.com/fengari-lua/fengari#readme",
"devDependencies": {
"eslint": "^4.19.1",
- "faucet": "^0.0.1",
- "tape": "^4.9.0"
+ "jest": "^22.4.3"
},
"dependencies": {
"readline-sync": "^1.4.9",
@@ -78,6 +77,16 @@
"error",
"always"
]
- }
+ },
+ "overrides": [
+ {
+ "files": [
+ "test/**/*.test.js"
+ ],
+ "env": {
+ "jest": true
+ }
+ }
+ ]
}
}
diff --git a/test/defs.test.js b/test/defs.test.js
new file mode 100644
index 0000000..4cc0ad9
--- /dev/null
+++ b/test/defs.test.js
@@ -0,0 +1,94 @@
+const defs = require('../src/defs.js');
+
+
+const unicode_tests = [
+ {
+ description: "Convert normal ascii string",
+ literal: "foo",
+ byte_array: defs.luastring_of("f".charCodeAt(0), "o".charCodeAt(0), "o".charCodeAt(0))
+ },
+ {
+ description: "Convert ascii string containing null byte",
+ literal: "fo\0o",
+ byte_array: defs.luastring_of("f".charCodeAt(0), "o".charCodeAt(0), 0, "o".charCodeAt(0))
+ },
+ {
+ description: "Convert string with BMP unicode chars",
+ literal: "Café",
+ byte_array: defs.luastring_of(67, 97, 102, 195, 169)
+ },
+ {
+ description: "Convert string with codepoint in PUA (U+E000 to U+F8FF)",
+ literal: "",
+ byte_array: defs.luastring_of(239, 163, 191)
+ },
+ {
+ description: "Convert string with surrogate pair",
+ literal: "❤️🍾",
+ byte_array: defs.luastring_of(226, 157, 164, 239, 184, 143, 240, 159, 141, 190)
+ },
+ {
+ description: "Convert string with broken surrogate pair",
+ literal: "\uD800a",
+ byte_array: defs.luastring_of(237, 160, 128, 97)
+ },
+ {
+ description: "Convert string with broken surrogate pair at end of string",
+ literal: "\uD823",
+ byte_array: defs.luastring_of(237, 160, 163)
+ }
+];
+
+describe('to_luastring', () => {
+ unicode_tests.forEach((v) => {
+ test(v.description, () => {
+ expect(defs.to_luastring(v.literal)).toEqual(v.byte_array);
+ });
+ });
+});
+
+describe('to_jsstring', () => {
+ unicode_tests.forEach((v) => {
+ test(v.description, () => {
+ expect(defs.to_jsstring(v.byte_array)).toEqual(v.literal);
+ });
+ });
+});
+
+
+describe('to_jsstring fails on invalid unicode', () => {
+ test("non-utf8 char", () => {
+ expect(() => defs.to_jsstring(defs.luastring_of(165)))
+ .toThrowError(RangeError);
+ });
+
+ test("invalid continuation byte", () => {
+ expect(() => defs.to_jsstring(defs.luastring_of(208, 60)))
+ .toThrowError(RangeError);
+ });
+
+ test("invalid continuation byte", () => {
+ expect(() => defs.to_jsstring(defs.luastring_of(225, 60, 145)))
+ .toThrowError(RangeError);
+ });
+
+ test("invalid continuation byte", () => {
+ expect(() => defs.to_jsstring(defs.luastring_of(225, 145, 60)))
+ .toThrowError(RangeError);
+ });
+
+ test("invalid continuation byte", () => {
+ expect(() => defs.to_jsstring(defs.luastring_of(242, 60, 145, 145)))
+ .toThrowError(RangeError);
+ });
+
+ test("invalid continuation byte", () => {
+ expect(() => defs.to_jsstring(defs.luastring_of(242, 145, 60, 145)))
+ .toThrowError(RangeError);
+ });
+
+ test("invalid continuation byte", () => {
+ expect(() => defs.to_jsstring(defs.luastring_of(242, 145, 145, 60)))
+ .toThrowError(RangeError);
+ });
+});
diff --git a/test/lapi.test.js b/test/lapi.test.js
new file mode 100644
index 0000000..f6bafc3
--- /dev/null
+++ b/test/lapi.test.js
@@ -0,0 +1,382 @@
+"use strict";
+
+const {toByteCode} = require("./tests.js");
+
+const lua = require('../src/lua.js');
+const lauxlib = require("../src/lauxlib.js");
+const {to_luastring} = require("../src/fengaricore.js");
+
+
+test('luaL_newstate, lua_pushnil, luaL_typename', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ {
+ lua.lua_pushnil(L);
+ }
+
+ expect(lauxlib.luaL_typename(L, -1))
+ .toEqual(to_luastring("nil"));
+});
+
+
+test('lua_pushnumber', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ {
+ lua.lua_pushnumber(L, 10.5);
+ }
+
+ expect(lauxlib.luaL_typename(L, -1))
+ .toEqual(to_luastring("number"));
+
+ expect(lua.lua_tonumber(L, -1))
+ .toBe(10.5);
+});
+
+
+test('lua_pushinteger', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ {
+ lua.lua_pushinteger(L, 10);
+ }
+
+ expect(lauxlib.luaL_typename(L, -1))
+ .toEqual(to_luastring("number"));
+
+ expect(lua.lua_tointeger(L, -1))
+ .toBe(10);
+});
+
+
+test('lua_pushliteral', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ {
+ lua.lua_pushliteral(L, "hello");
+ }
+
+ expect(lauxlib.luaL_typename(L, -1))
+ .toEqual(to_luastring("string"));
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe("hello");
+});
+
+
+test('lua_pushboolean', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ {
+ lua.lua_pushboolean(L, true);
+ }
+
+ expect(lauxlib.luaL_typename(L, -1))
+ .toEqual(to_luastring("boolean"));
+
+ expect(lua.lua_toboolean(L, -1))
+ .toBe(true);
+});
+
+
+test('lua_pushvalue', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ {
+ lua.lua_pushliteral(L, "hello");
+ lua.lua_pushvalue(L, -1);
+ }
+
+ expect(lauxlib.luaL_typename(L, -1))
+ .toEqual(to_luastring("string"));
+
+ expect(lauxlib.luaL_typename(L, -2))
+ .toEqual(to_luastring("string"));
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe("hello");
+
+ expect(lua.lua_tojsstring(L, -2))
+ .toBe("hello");
+});
+
+
+test('lua_pushjsclosure', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ {
+ let fn = function(L) {
+ return 0;
+ };
+ lua.lua_pushliteral(L, "a value associated to the C closure");
+ lua.lua_pushjsclosure(L, fn, 1);
+ }
+
+ expect(lauxlib.luaL_typename(L, -1))
+ .toEqual(to_luastring("function"));
+});
+
+
+test('lua_pushjsfunction', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ {
+ let fn = function(L) {
+ return 0;
+ };
+ lua.lua_pushjsfunction(L, fn);
+ }
+
+ expect(lauxlib.luaL_typename(L, -1))
+ .toEqual(to_luastring("function"));
+});
+
+
+test('lua_call (calling a light JS function)', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ {
+ let fn = function(L) {
+ lua.lua_pushliteral(L, "hello");
+ return 1;
+ };
+ lua.lua_pushjsfunction(L, fn);
+ lua.lua_call(L, 0, 1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe("hello");
+});
+
+
+test('lua_call (calling a JS closure)', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ {
+ let fn = function(L) {
+ lua.lua_pushstring(L, lua.lua_tostring(L, lua.lua_upvalueindex(1)));
+ return 1;
+ };
+ lua.lua_pushliteral(L, "upvalue hello!");
+ lua.lua_pushjsclosure(L, fn, 1);
+ lua.lua_call(L, 0, 1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe("upvalue hello!");
+});
+
+
+test('lua_pcall (calling a light JS function)', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ {
+ let fn = function(L) {
+ lua.lua_pushliteral(L, "hello");
+ return 1;
+ };
+ lua.lua_pushjsfunction(L, fn);
+ expect(lua.lua_pcall(L, 0, 1, 0)).toBe(lua.LUA_OK);
+ }
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe("hello");
+});
+
+
+test('lua_pcall that breaks', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ {
+ let fn = function(L) {
+ return "undefined_value";
+ };
+ lua.lua_pushjsfunction(L, fn);
+ expect(lua.lua_pcall(L, 0, 1, 0)).not.toBe(lua.LUA_OK);
+ }
+});
+
+
+test('lua_pop', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ {
+ lua.lua_pushliteral(L, "hello");
+ lua.lua_pushliteral(L, "world");
+ lua.lua_pop(L, 1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe("hello");
+});
+
+
+test('lua_load with no chunkname', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ {
+ lua.lua_load(L, function(L, s) {
+ let r = s.code;
+ s.code = null;
+ return r;
+ }, {
+ code: to_luastring("return 'hello'")
+ }, null, null);
+ lua.lua_call(L, 0, 1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe("hello");
+});
+
+test('lua_load and lua_call it', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ {
+ let luaCode = `
+ local a = "JS > Lua > JS \\\\o/"
+ return a
+ `;
+ let bc = toByteCode(luaCode);
+ lua.lua_load(L, function(L, s) {
+ let r = s.bc;
+ s.bc = null;
+ return r;
+ }, {bc: bc}, to_luastring("test-lua_load"), to_luastring("binary"));
+ lua.lua_call(L, 0, 1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe("JS > Lua > JS \\o/");
+});
+
+
+test('lua script reads js upvalues', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ {
+ let luaCode = `
+ return js .. " world"
+ `;
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_pushliteral(L, "hello");
+ lua.lua_setglobal(L, to_luastring("js"));
+ lua.lua_call(L, 0, 1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe("hello world");
+});
+
+
+test('lua_createtable', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ {
+ lua.lua_createtable(L, 3, 3);
+ }
+
+ expect(lua.lua_istable(L, -1)).toBe(true);
+});
+
+
+test('lua_newtable', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ {
+ lua.lua_newtable(L);
+ }
+
+ expect(lua.lua_istable(L, -1)).toBe(true);
+});
+
+
+test('lua_settable, lua_gettable', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ {
+ lua.lua_newtable(L);
+
+ lua.lua_pushliteral(L, "key");
+ lua.lua_pushliteral(L, "value");
+
+ lua.lua_settable(L, -3);
+
+ lua.lua_pushliteral(L, "key");
+ lua.lua_gettable(L, -2);
+ }
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe("value");
+});
+
+describe('lua_atnativeerror', () => {
+ test('no native error handler', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let errob = {};
+
+ lua.lua_pushcfunction(L, function(L) {
+ throw errob;
+ });
+ // without a native error handler pcall should be -1
+ expect(lua.lua_pcall(L, 0, 0, 0)).toBe(-1);
+ });
+
+ test('native error handler returns string', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let errob = {};
+
+ lua.lua_atnativeerror(L, function(L) {
+ let e = lua.lua_touserdata(L, 1);
+ expect(e).toBe(errob);
+ lua.lua_pushstring(L, to_luastring("runtime error!"));
+ return 1;
+ });
+ lua.lua_pushcfunction(L, function(L) {
+ throw errob;
+ });
+ expect(lua.lua_pcall(L, 0, 0, 0)).toBe(lua.LUA_ERRRUN);
+ expect(lua.lua_tojsstring(L, -1)).toBe("runtime error!");
+ });
+
+ test('native error handler rethrows lua error', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let errob = {};
+
+ lua.lua_atnativeerror(L, function(L) {
+ let e = lua.lua_touserdata(L, 1);
+ expect(e).toBe(errob);
+ lauxlib.luaL_error(L, to_luastring("runtime error!"));
+ });
+ lua.lua_pushcfunction(L, function(L) {
+ throw errob;
+ });
+ expect(lua.lua_pcall(L, 0, 0, 0)).toBe(lua.LUA_ERRRUN);
+ expect(lua.lua_tojsstring(L, -1)).toBe("runtime error!");
+ });
+});
diff --git a/tests/lauxlib.js b/test/lauxlib.test.js
index 8d57ecb..62198ac 100644
--- a/tests/lauxlib.js
+++ b/test/lauxlib.test.js
@@ -1,29 +1,22 @@
"use strict";
-const test = require('tape');
-
-const lua = require('../src/lua.js');
+const lua = require('../src/lua.js');
const lauxlib = require("../src/lauxlib.js");
const {to_luastring} = require("../src/fengaricore.js");
-test('luaL_ref, lua_rawgeti, luaL_unref, LUA_REGISTRYINDEX', function (t) {
- let L;
- t.plan(2);
+test('luaL_ref, lua_rawgeti, luaL_unref, LUA_REGISTRYINDEX', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
+ {
lua.lua_pushstring(L, to_luastring("hello references!"));
let r = lauxlib.luaL_ref(L, lua.LUA_REGISTRYINDEX); // pops a value, stores it and returns a reference
lua.lua_rawgeti(L, lua.LUA_REGISTRYINDEX, r); // pushes a value associated with the reference
lauxlib.luaL_unref(L, lua.LUA_REGISTRYINDEX, r); // releases the reference
+ }
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello references!",
- "top is correct"
- );
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe("hello references!");
});
diff --git a/test/lbaselib.test.js b/test/lbaselib.test.js
new file mode 100644
index 0000000..dc30a98
--- /dev/null
+++ b/test/lbaselib.test.js
@@ -0,0 +1,435 @@
+"use strict";
+
+const lua = require('../src/lua.js');
+const lauxlib = require('../src/lauxlib.js');
+const lualib = require('../src/lualib.js');
+const {to_luastring} = require("../src/fengaricore.js");
+
+
+test('print', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ print("hello", "world", 123)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+});
+
+
+test('setmetatable, getmetatable', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local mt = {
+ __index = function ()
+ return "hello"
+ end
+ }
+
+ local t = {}
+
+ setmetatable(t, mt);
+
+ return t[1], getmetatable(t)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -2))
+ .toBe("hello");
+
+ expect(lua.lua_istable(L, -1)).toBe(true);
+});
+
+
+test('rawequal', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local mt = {
+ __eq = function ()
+ return true
+ end
+ }
+
+ local t1 = {}
+ local t2 = {}
+
+ setmetatable(t1, mt);
+
+ return rawequal(t1, t2), t1 == t2
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_toboolean(L, -2)).toBe(false);
+
+ expect(lua.lua_toboolean(L, -1)).toBe(true);
+});
+
+
+test('rawset, rawget', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local mt = {
+ __newindex = function (table, key, value)
+ rawset(table, key, "hello")
+ end
+ }
+
+ local t = {}
+
+ setmetatable(t, mt);
+
+ t["yo"] = "bye"
+ rawset(t, "yoyo", "bye")
+
+ return rawget(t, "yo"), t["yo"], rawget(t, "yoyo"), t["yoyo"]
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -4))
+ .toBe("hello");
+
+ expect(lua.lua_tojsstring(L, -3))
+ .toBe("hello");
+
+ expect(lua.lua_tojsstring(L, -2))
+ .toBe("bye");
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe("bye");
+});
+
+
+test('type', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return type(1), type(true), type("hello"), type({}), type(nil)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -5))
+ .toBe("number");
+
+ expect(lua.lua_tojsstring(L, -4))
+ .toBe("boolean");
+
+ expect(lua.lua_tojsstring(L, -3))
+ .toBe("string");
+
+ expect(lua.lua_tojsstring(L, -2))
+ .toBe("table");
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe("nil");
+});
+
+
+test('error', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ error("you fucked up")
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ expect(() => {
+ lua.lua_call(L, 0, -1);
+ }).toThrow(/you fucked up/);
+ }
+});
+
+
+test('error, protected', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ error("you fucked up")
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_pcall(L, 0, -1, 0);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toMatch(/you fucked up/);
+});
+
+
+test('pcall', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local willFail = function ()
+ error("you fucked up")
+ end
+
+ return pcall(willFail)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toMatch(/you fucked up/);
+});
+
+
+test('xpcall', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local willFail = function ()
+ error("you fucked up")
+ end
+
+ local msgh = function (err)
+ return "Something's wrong: " .. err
+ end
+
+ return xpcall(willFail, msgh)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toMatch(/Something's wrong: .*you fucked up/);
+});
+
+
+test('ipairs', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local t = {1, 2, 3, 4, 5, ['yo'] = 'lo'}
+
+ local sum = 0
+ for i, v in ipairs(t) do
+ sum = sum + v
+ end
+
+ return sum
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tointeger(L, -1)).toBe(15);
+});
+
+
+test('select', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return {select('#', 1, 2, 3)}, {select(2, 1, 2, 3)}, {select(-2, 1, 2, 3)}
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect([...lua.lua_topointer(L, -3).strong.entries()].map(e => e[1].value.value))
+ .toEqual([3]);
+
+ expect([...lua.lua_topointer(L, -2).strong.entries()].map(e => e[1].value.value).sort())
+ .toEqual([2, 3]);
+
+ expect([...lua.lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).sort())
+ .toEqual([2, 3]);
+});
+
+
+test('tonumber', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return tonumber('foo'),
+ tonumber('123'),
+ tonumber('12.3'),
+ tonumber('az', 36),
+ tonumber('10', 2)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_isnil(L, -5)).toBe(true);
+ expect(lua.lua_tonumber(L, -4)).toBe(123);
+ expect(lua.lua_tonumber(L, -3)).toBe(12.3);
+ expect(lua.lua_tonumber(L, -2)).toBe(395);
+ expect(lua.lua_tonumber(L, -1)).toBe(2);
+});
+
+
+test('assert', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ assert(1 < 0, "this doesn't makes sense")
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_pcall(L, 0, -1, 0);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toMatch(/this doesn't makes sense/);
+});
+
+
+test('rawlen', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return rawlen({1, 2, 3}), rawlen('hello')
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tonumber(L, -2)).toBe(3);
+ expect(lua.lua_tonumber(L, -1)).toBe(5);
+});
+
+
+test('next', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local total = 0
+ local t = {
+ 1,
+ two = 2,
+ 3,
+ four = 4
+ }
+
+ for k,v in next, t, nil do
+ total = total + v
+ end
+
+ return total
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tonumber(L, -1)).toBe(10);
+});
+
+
+test('pairs', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local total = 0
+ local t = {
+ 1,
+ two = 2,
+ 3,
+ four = 4
+ }
+
+ for k,v in pairs(t) do
+ total = total + v
+ end
+
+ return total
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tonumber(L, -1)).toBe(10);
+});
+
+
+test('pairs with __pairs', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local total = 0
+
+ local mt = {
+ __pairs = function(t)
+ return next, {5, 6, 7, 8}, nil
+ end
+ }
+
+ local t = {
+ 1,
+ two = 2,
+ 3,
+ four = 4
+ }
+
+ setmetatable(t, mt)
+
+ for k,v in pairs(t) do
+ total = total + v
+ end
+
+ return total
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tonumber(L, -1)).toBe(26);
+});
diff --git a/test/lcorolib.test.js b/test/lcorolib.test.js
new file mode 100644
index 0000000..e9ad8ed
--- /dev/null
+++ b/test/lcorolib.test.js
@@ -0,0 +1,143 @@
+"use strict";
+
+const lua = require('../src/lua.js');
+const lauxlib = require('../src/lauxlib.js');
+const lualib = require('../src/lualib.js');
+const lstate = require('../src/lstate.js');
+const {to_luastring} = require("../src/fengaricore.js");
+
+test('coroutine.create, coroutine.yield, coroutine.resume', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local co = coroutine.create(function (start)
+ local b = coroutine.yield(start * start);
+ coroutine.yield(b * b)
+ end)
+
+ local success, pow = coroutine.resume(co, 5)
+ success, pow = coroutine.resume(co, pow)
+
+ return pow
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tonumber(L, -1))
+ .toBe(625);
+});
+
+
+test('coroutine.status', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local co = coroutine.create(function (start)
+ local b = coroutine.yield(start * start);
+ coroutine.yield(b * b)
+ end)
+
+ local s1 = coroutine.status(co)
+
+ local success, pow = coroutine.resume(co, 5)
+ success, pow = coroutine.resume(co, pow)
+
+ coroutine.resume(co, pow)
+
+ local s2 = coroutine.status(co)
+
+ return s1, s2
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -2))
+ .toBe("suspended");
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe("dead");
+});
+
+
+test('coroutine.isyieldable', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local co = coroutine.create(function ()
+ coroutine.yield(coroutine.isyieldable());
+ end)
+
+ local succes, yieldable = coroutine.resume(co)
+
+ return yieldable, coroutine.isyieldable()
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_toboolean(L, -2)).toBe(true);
+ expect(lua.lua_toboolean(L, -1)).toBe(false);
+});
+
+
+test('coroutine.running', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local running, ismain
+
+ local co = coroutine.create(function ()
+ running, ismain = coroutine.running()
+ end)
+
+ coroutine.resume(co)
+
+ return running, ismain
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tothread(L, -2)).toBeInstanceOf(lstate.lua_State);
+ expect(lua.lua_toboolean(L, -1)).toBe(false);
+});
+
+
+test('coroutine.wrap', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local co = coroutine.wrap(function (start)
+ local b = coroutine.yield(start * start);
+ coroutine.yield(b * b)
+ end)
+
+ pow = co(5)
+ pow = co(pow)
+
+ return pow
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tonumber(L, -1))
+ .toBe(625);
+});
diff --git a/test/ldblib.test.js b/test/ldblib.test.js
new file mode 100644
index 0000000..ba68853
--- /dev/null
+++ b/test/ldblib.test.js
@@ -0,0 +1,310 @@
+"use strict";
+
+const lua = require('../src/lua.js');
+const lauxlib = require('../src/lauxlib.js');
+const lualib = require('../src/lualib.js');
+const {to_luastring} = require("../src/fengaricore.js");
+
+test('debug.sethook', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local result = ""
+
+ debug.sethook(function (event)
+ result = result .. event .. " "
+ end, "crl", 1)
+
+ local l = function() end
+
+ l()
+ l()
+ l()
+
+ return result
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe("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 ");
+});
+
+
+test('debug.gethook', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local result = ""
+
+ debug.sethook(function (event)
+ result = result .. event .. " "
+ end, "crl", 1)
+
+ local l = function() end
+
+ l()
+ l()
+ l()
+
+ return debug.gethook()
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_typename(L, lua.lua_type(L, -3)))
+ .toEqual(to_luastring("function"));
+ expect(lua.lua_tojsstring(L, -2)).toBe("crl");
+ expect(lua.lua_tointeger(L, -1)).toBe(1);
+});
+
+
+test('debug.getlocal', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local alocal = "alocal"
+ local another = "another"
+
+ local result = ""
+
+ local l = function()
+ local infunction = "infunction"
+ local anotherin = "anotherin"
+ result = table.concat(table.pack(debug.getlocal(2, 1)), " ")
+ .. table.concat(table.pack(debug.getlocal(2, 2)), " ")
+ .. table.concat(table.pack(debug.getlocal(1, 1)), " ")
+ .. table.concat(table.pack(debug.getlocal(1, 2)), " ")
+ end
+
+ l()
+
+ return result
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe("alocal alocalanother anotherinfunction infunctionanotherin anotherin");
+});
+
+test('debug.setlocal', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local alocal = "alocal"
+ local another = "another"
+
+ local l = function()
+ local infunction = "infunction"
+ local anotherin = "anotherin"
+
+ debug.setlocal(2, 1, 1)
+ debug.setlocal(2, 2, 2)
+ debug.setlocal(1, 1, 3)
+ debug.setlocal(1, 2, 4)
+
+ return infunction, anotherin
+ end
+
+ local a, b = l()
+
+ return alocal, another, a, b
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tointeger(L, -4)).toBe(1);
+ expect(lua.lua_tointeger(L, -3)).toBe(2);
+ expect(lua.lua_tointeger(L, -2)).toBe(3);
+ expect(lua.lua_tointeger(L, -1)).toBe(4);
+});
+
+test('debug.upvalueid', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local upvalue = "upvalue"
+
+ local l = function()
+ return upvalue
+ end
+
+ return debug.upvalueid(l, 1)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_touserdata(L, -1)).toBeTruthy();
+});
+
+
+test('debug.upvaluejoin', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local upvalue1 = "upvalue1"
+ local upvalue2 = "upvalue2"
+
+ local l1 = function()
+ return upvalue1
+ end
+
+ local l2 = function()
+ return upvalue2
+ end
+
+ debug.upvaluejoin(l1, 1, l2, 1)
+
+ return l1()
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe("upvalue2");
+});
+
+
+test('debug.traceback (with a global)', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local trace
+
+ rec = function(n)
+ n = n or 0
+ if n < 10 then
+ rec(n + 1)
+ else
+ trace = debug.traceback()
+ end
+ end
+
+ rec()
+
+ return trace
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ luaCode = to_luastring(luaCode);
+ lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring("traceback-test"));
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe(`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'
+\t[string "traceback-test"]:7: in function 'rec'
+\t[string "traceback-test"]:7: in function 'rec'
+\t[string "traceback-test"]:7: in function 'rec'
+\t[string "traceback-test"]:7: in function 'rec'
+\t[string "traceback-test"]:7: in function 'rec'
+\t[string "traceback-test"]:7: in function 'rec'
+\t[string "traceback-test"]:7: in function 'rec'
+\t[string "traceback-test"]:7: in function 'rec'
+\t[string "traceback-test"]:13: in main chunk`);
+});
+
+
+test('debug.traceback (with a upvalue)', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local trace
+ local rec
+
+ rec = function(n)
+ n = n or 0
+ if n < 10 then
+ rec(n + 1)
+ else
+ trace = debug.traceback()
+ end
+ end
+
+ rec()
+
+ return trace
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ luaCode = to_luastring(luaCode);
+ lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring("traceback-test"));
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe(`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'
+\t[string "traceback-test"]:8: in upvalue 'rec'
+\t[string "traceback-test"]:8: in upvalue 'rec'
+\t[string "traceback-test"]:8: in upvalue 'rec'
+\t[string "traceback-test"]:8: in upvalue 'rec'
+\t[string "traceback-test"]:8: in upvalue 'rec'
+\t[string "traceback-test"]:8: in upvalue 'rec'
+\t[string "traceback-test"]:8: in upvalue 'rec'
+\t[string "traceback-test"]:8: in local 'rec'
+\t[string "traceback-test"]:14: in main chunk`);
+});
+
+test('debug.getinfo', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local alocal = function(p1, p2) end
+ global = function() return alocal end
+
+ local d1 = debug.getinfo(alocal)
+ local d2 = debug.getinfo(global)
+
+ return d1.short_src, d1.nups, d1.what, d1.nparams,
+ d2.short_src, d2.nups, d2.what, d2.nparams
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ luaCode = to_luastring(luaCode);
+ lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring("getinfo-test"));
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -8)).toBe(`[string "getinfo-test"]`);
+ expect(lua.lua_tointeger(L, -7)).toBe(0);
+ expect(lua.lua_tojsstring(L, -6)).toBe(`Lua`);
+ expect(lua.lua_tointeger(L, -5)).toBe(2);
+ expect(lua.lua_tojsstring(L, -4)).toBe(`[string "getinfo-test"]`);
+ expect(lua.lua_tointeger(L, -3)).toBe(1);
+ expect(lua.lua_tojsstring(L, -2)).toBe(`Lua`);
+ expect(lua.lua_tointeger(L, -1)).toBe(0);
+});
diff --git a/test/ldebug.test.js b/test/ldebug.test.js
new file mode 100644
index 0000000..d52cfcb
--- /dev/null
+++ b/test/ldebug.test.js
@@ -0,0 +1,135 @@
+"use strict";
+
+const lua = require('../src/lua.js');
+const lauxlib = require('../src/lauxlib.js');
+const lualib = require('../src/lualib.js');
+const {to_luastring} = require("../src/fengaricore.js");
+
+test('luaG_typeerror', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local a = true
+ return #a
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_pcall(L, 0, -1, 0);
+ }
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toMatch("attempt to get length of a boolean value (local 'a')");
+});
+
+
+test('luaG_typeerror', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local a = true
+ return a.yo
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_pcall(L, 0, -1, 0);
+ }
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toMatch("attempt to index a boolean value (local 'a')");
+});
+
+
+test('luaG_typeerror', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local a = true
+ return a.yo
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_pcall(L, 0, -1, 0);
+ }
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toMatch("attempt to index a boolean value (local 'a')");
+});
+
+
+test('luaG_typeerror', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local a = true
+ a.yo = 1
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_pcall(L, 0, -1, 0);
+ }
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toMatch("attempt to index a boolean value (local 'a')");
+});
+
+
+test('luaG_concaterror', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return {} .. 'hello'
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_pcall(L, 0, -1, 0);
+ }
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toMatch("attempt to concatenate a table value");
+});
+
+
+test('luaG_opinterror', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return {} + 'hello'
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_pcall(L, 0, -1, 0);
+ }
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toMatch("attempt to perform arithmetic on a table value");
+});
+
+
+test('luaG_tointerror', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return 123.5 & 12
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_pcall(L, 0, -1, 0);
+ }
+
+ expect(lua.lua_tojsstring(L, -1))
+ .toMatch("number has no integer representation");
+});
diff --git a/tests/lexparse.js b/test/lexparse.test.js
index e9087ee..a9407ed 100644
--- a/tests/lexparse.js
+++ b/test/lexparse.test.js
@@ -1,7 +1,5 @@
"use strict";
-const test = require('tape');
-
const lua = require('../src/lua.js');
const lauxlib = require('../src/lauxlib.js');
const lualib = require('../src/lualib.js');
@@ -9,202 +7,135 @@ const lstring = require("../src/lstring.js");
const {to_luastring} = require("../src/fengaricore.js");
// Roughly the same tests as test/lvm.js to cover all opcodes
-test('LOADK, RETURN', function (t) {
+test('LOADK, RETURN', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = "hello world"
return a
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello world",
- "Correct element(s) on the stack"
- );
-
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello world");
});
-test('MOVE', function (t) {
+test('MOVE', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = "hello world"
local b = a
return b
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello world",
- "Correct element(s) on the stack"
- );
-
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello world");
});
-test('Binary op', function (t) {
+test('Binary op', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = 5
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 () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.deepEqual(
- L.stack.slice(L.top - 12, L.top).map(e => e.value),
- [15, -5, 50, 0.5, 5, 9765625.0, 0, 0, 15, 15, 5120, 0],
- "Program output is correct"
- );
-
+ expect(L.stack.slice(L.top - 12, L.top).map(e => e.value))
+ .toEqual([15, -5, 50, 0.5, 5, 9765625.0, 0, 0, 15, 15, 5120, 0]);
});
-test('Unary op, LOADBOOL', function (t) {
+test('Unary op, LOADBOOL', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = 5
local b = false
return -a, not b, ~a
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.deepEqual(
- L.stack.slice(L.top - 3, L.top).map(e => e.value),
- [-5, true, -6],
- "Program output is correct"
- );
+ expect(L.stack.slice(L.top - 3, L.top).map(e => e.value))
+ .toEqual([-5, true, -6]);
});
-test('NEWTABLE', function (t) {
+test('NEWTABLE', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = {}
return a
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.ok(
- lua.lua_type(L, -1) === lua.LUA_TTABLE,
- "Program output is correct"
- );
+ expect(lua.lua_type(L, -1)).toBe(lua.LUA_TTABLE);
});
-test('CALL', function (t) {
+test('CALL', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local f = function (a, b)
return a + b
@@ -213,40 +144,26 @@ test('CALL', function (t) {
local c = f(1, 2)
return c
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 3,
- "Program output is correct"
- );
+ expect(lua.lua_tointeger(L, -1)).toBe(3);
});
-test('Multiple return', function (t) {
+test('Multiple return', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local f = function (a, b)
return a + b, a - b, a * b
@@ -259,320 +176,210 @@ test('Multiple return', function (t) {
c, d, e = f(1,2)
return c, d, e
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.deepEqual(
- L.stack.slice(L.top - 3, L.top).map(e => e.value),
- [3, -1, 2],
- "Program output is correct"
- );
+ expect(L.stack.slice(L.top - 3, L.top).map(e => e.value))
+ .toEqual([3, -1, 2]);
});
-test('TAILCALL', function (t) {
+test('TAILCALL', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local f = function (a, b)
return a + b
end
return f(1,2)
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 3,
- "Program output is correct"
- );
+ expect(lua.lua_tointeger(L, -1)).toBe(3);
});
-test('VARARG', function (t) {
+test('VARARG', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local f = function (...)
return ...
end
return f(1,2,3)
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.deepEqual(
- L.stack.slice(L.top - 3, L.top).map(e => e.value),
- [1, 2, 3],
- "Program output is correct"
- );
+ expect(L.stack.slice(L.top - 3, L.top).map(e => e.value))
+ .toEqual([1, 2, 3]);
});
-test('LE, JMP', function (t) {
+test('LE, JMP', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a, b = 1, 1
return a >= b
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_toboolean(L, -1),
- true,
- "Program output is correct"
- );
+ expect(lua.lua_toboolean(L, -1)).toBe(true);
});
-test('LT', function (t) {
+test('LT', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a, b = 1, 1
return a > b
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_toboolean(L, -1),
- false,
- "Program output is correct"
- );
+ expect(lua.lua_toboolean(L, -1)).toBe(false);
});
-test('EQ', function (t) {
+test('EQ', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a, b = 1, 1
return a == b
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_toboolean(L, -1),
- true,
- "Program output is correct"
- );
+ expect(lua.lua_toboolean(L, -1)).toBe(true);
});
-test('TESTSET (and)', function (t) {
+test('TESTSET (and)', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = true
local b = "hello"
return a and b
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello",
- "Program output is correct"
- );
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello");
});
-test('TESTSET (or)', function (t) {
+test('TESTSET (or)', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = false
local b = "hello"
return a or b
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello",
- "Program output is correct"
- );
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello");
});
-test('TEST (false)', function (t) {
+test('TEST (false)', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = false
local b = "hello"
@@ -582,41 +389,27 @@ test('TEST (false)', function (t) {
end
return "goodbye"
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "goodbye",
- "Program output is correct"
- );
+ expect(lua.lua_tojsstring(L, -1)).toBe("goodbye");
});
-test('FORPREP, FORLOOP (int)', function (t) {
+test('FORPREP, FORLOOP (int)', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local total = 0
@@ -625,41 +418,27 @@ test('FORPREP, FORLOOP (int)', function (t) {
end
return total
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 55,
- "Program output is correct"
- );
+ expect(lua.lua_tointeger(L, -1)).toBe(55);
});
-test('FORPREP, FORLOOP (float)', function (t) {
+test('FORPREP, FORLOOP (float)', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local total = 0
@@ -668,41 +447,27 @@ test('FORPREP, FORLOOP (float)', function (t) {
end
return total
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tonumber(L, -1),
- 60.5,
- "Program output is correct"
- );
+ expect(lua.lua_tonumber(L, -1)).toBe(60.5);
});
-test('SETTABLE, GETTABLE', function (t) {
+test('SETTABLE, GETTABLE', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local t = {}
@@ -710,47 +475,30 @@ test('SETTABLE, GETTABLE', function (t) {
t["two"] = "world"
return t
- `, L;
-
- t.plan(4);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_topointer(L, -1).strong.get(1).value.jsstring(),
- "hello",
- "Program output is correct"
- );
-
- t.strictEqual(
- lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring(),
- "world",
- "Program output is correct"
- );
+ expect(lua.lua_topointer(L, -1).strong.get(1).value.jsstring())
+ .toBe("hello");
+ expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring())
+ .toBe("world");
});
-test('SETUPVAL, GETUPVAL', function (t) {
+test('SETUPVAL, GETUPVAL', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local up = "hello"
@@ -761,41 +509,27 @@ test('SETUPVAL, GETUPVAL', function (t) {
end
return f()
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "world",
- "Program output is correct"
- );
+ expect(lua.lua_tojsstring(L, -1)).toBe("world");
});
-test('SETTABUP, GETTABUP', function (t) {
+test('SETTABUP, GETTABUP', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
t = {}
@@ -803,47 +537,30 @@ test('SETTABUP, GETTABUP', function (t) {
t["two"] = "world"
return t
- `, L;
-
- t.plan(4);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_topointer(L, -1).strong.get(1).value.jsstring(),
- "hello",
- "Program output is correct"
- );
-
- t.strictEqual(
- lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring(),
- "world",
- "Program output is correct"
- );
+ expect(lua.lua_topointer(L, -1).strong.get(1).value.jsstring())
+ .toBe("hello");
+ expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring())
+ .toBe("world");
});
-test('SELF', function (t) {
+test('SELF', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local t = {}
@@ -853,80 +570,53 @@ test('SELF', function (t) {
end
return t:get()
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello",
- "Program output is correct"
- );
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello");
});
-test('SETLIST', function (t) {
+test('SETLIST', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local t = {1, 2, 3, 4, 5, 6, 7, 8, 9}
return t
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.deepEqual(
- [...lua.lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).sort(),
- [1, 2, 3, 4, 5, 6, 7, 8, 9],
- "Program output is correct"
- );
+ expect([...lua.lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).sort())
+ .toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9]);
});
-test('Variable SETLIST', function (t) {
+test('Variable SETLIST', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = function ()
return 6, 7, 8, 9
@@ -935,79 +625,53 @@ test('Variable SETLIST', function (t) {
local t = {1, 2, 3, 4, 5, a()}
return t
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.deepEqual(
- [...lua.lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).sort(),
- [1, 2, 3, 4, 5, 6, 7, 8, 9],
- "Program output is correct"
- );
+ expect([...lua.lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).sort())
+ .toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9]);
});
-test('Long SETLIST', function (t) {
+test('Long SETLIST', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local t = {1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5}
return t
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.deepEqual(
- [...lua.lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).reverse(),
- [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],
- "Program output is correct"
- );
+ expect([...lua.lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).reverse())
+ .toEqual([1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]);
});
-test('TFORCALL, TFORLOOP', function (t) {
+test('TFORCALL, TFORLOOP', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local iterator = function (t, i)
i = i + 1
@@ -1028,125 +692,70 @@ test('TFORCALL, TFORLOOP', function (t) {
end
return r
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tonumber(L, -1),
- 6,
- "Program output is correct"
- );
+ expect(lua.lua_tonumber(L, -1)).toBe(6);
});
-test('LEN', function (t) {
+test('LEN', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local t = {[10000] = "foo"}
local t2 = {1, 2, 3}
local s = "hello"
return #t, #t2, #s
- `, L;
-
- t.plan(5);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tonumber(L, -1),
- 5,
- "Program output is correct"
- );
-
- t.strictEqual(
- lua.lua_tonumber(L, -2),
- 3,
- "Program output is correct"
- );
-
- t.strictEqual(
- lua.lua_tonumber(L, -3),
- 0,
- "Program output is correct"
- );
+ expect(lua.lua_tonumber(L, -1)).toBe(5);
+ expect(lua.lua_tonumber(L, -2)).toBe(3);
+ expect(lua.lua_tonumber(L, -3)).toBe(0);
});
-test('CONCAT', function (t) {
+test('CONCAT', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
return "hello " .. 2 .. " you"
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
+ `;
+ {
lualib.luaL_openlibs(L);
-
let reader = function(L, data) {
let code = luaCode ? luaCode.trim() : null;
luaCode = null;
return code ? to_luastring(code) : null;
};
-
lua.lua_load(L, reader, luaCode, to_luastring("test"), to_luastring("text"));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
lua.lua_call(L, 0, -1);
+ }
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello 2 you",
- "Program output is correct"
- );
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello 2 you");
});
diff --git a/tests/lib-hello.js.mod b/test/lib-hello.js.mod
index d4c02e1..d4c02e1 100644
--- a/tests/lib-hello.js.mod
+++ b/test/lib-hello.js.mod
diff --git a/test/lmathlib.test.js b/test/lmathlib.test.js
new file mode 100644
index 0000000..0ee0b1c
--- /dev/null
+++ b/test/lmathlib.test.js
@@ -0,0 +1,251 @@
+"use strict";
+
+const lua = require('../src/lua.js');
+const lauxlib = require('../src/lauxlib.js');
+const lualib = require('../src/lualib.js');
+const {to_luastring} = require("../src/fengaricore.js");
+
+test('math.abs, math.sin, math.cos, math.tan, math.asin, math.acos, math.atan', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return math.abs(-10), math.abs(-10.5), math.cos(10), math.tan(10),
+ math.asin(1), math.acos(0.5), math.atan(10)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tointeger(L, -7)).toBe(10);
+ expect(lua.lua_tonumber(L, -6)).toBe(10.5);
+ expect(lua.lua_tonumber(L, -5)).toBe(-0.8390715290764524);
+ expect(lua.lua_tonumber(L, -4)).toBe(0.6483608274590866);
+ expect(lua.lua_tonumber(L, -3)).toBe(1.5707963267948966);
+ expect(lua.lua_tonumber(L, -2)).toBe(1.0471975511965979);
+ expect(lua.lua_tonumber(L, -1)).toBe(1.4711276743037347);
+});
+
+
+test('math.ceil, math.floor', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return math.ceil(10.5), math.floor(10.5)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tointeger(L, -2)).toBe(11);
+ expect(lua.lua_tointeger(L, -1)).toBe(10);
+});
+
+
+test('math.deg, math.rad', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return math.deg(10), math.rad(10)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tonumber(L, -2)).toBe(572.9577951308232);
+ expect(lua.lua_tonumber(L, -1)).toBe(0.17453292519943295);
+});
+
+
+test('math.log', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return math.log(10), math.log(10, 2), math.log(10, 10)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tonumber(L, -3)).toBe(2.302585092994046);
+ expect(lua.lua_tonumber(L, -2)).toBe(3.321928094887362);
+ expect(lua.lua_tonumber(L, -1)).toBe(1);
+});
+
+
+/* Node.js 6 has incorrect results for Math.exp */
+(parseInt(process.versions.node) > 6 ? test : test.skip)('math.exp', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return math.exp(10)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tonumber(L, -1)).toBe(22026.465794806718);
+});
+
+
+test('math.min, math.max', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return math.max(10, 5, 23), math.min(10, 5, 23)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tonumber(L, -2)).toBe(23);
+ expect(lua.lua_tonumber(L, -1)).toBe(5);
+});
+
+
+test('math.random', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return math.random(), math.random(10, 15)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ {
+ let r = expect(lua.lua_tonumber(L, -2));
+ r.toBeGreaterThanOrEqual(0);
+ r.toBeLessThanOrEqual(1);
+ }
+ {
+ let r = expect(lua.lua_tonumber(L, -1));
+ r.toBeGreaterThanOrEqual(10);
+ r.toBeLessThanOrEqual(15);
+ }
+});
+
+
+test('math.sqrt', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return math.sqrt(10)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tonumber(L, -1)).toBe(3.1622776601683795);
+});
+
+
+test('math.tointeger', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return math.tointeger('10')
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tonumber(L, -1)).toBe(10);
+});
+
+
+test('math.type', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return math.type(10), math.type(10.5), math.type('hello')
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -3)).toBe("integer");
+ expect(lua.lua_tojsstring(L, -2)).toBe("float");
+ expect(lua.lua_tojsstring(L, -1)).toBe(null);
+});
+
+
+test('math.ult', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return math.ult(5, 200)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_toboolean(L, -1)).toBe(true);
+});
+
+
+test('math.fmod', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return math.fmod(2,5)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tonumber(L, -1)).toBe(2);
+});
+
+
+test('math.modf', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return math.modf(3.4, 0.6)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tonumber(L, -2)).toBe(3);
+ expect(lua.lua_tonumber(L, -1)).toBe(0.3999999999999999);
+});
diff --git a/test/load.test.js b/test/load.test.js
new file mode 100644
index 0000000..3c03eec
--- /dev/null
+++ b/test/load.test.js
@@ -0,0 +1,115 @@
+"use strict";
+
+const {toByteCode} = require("./tests.js");
+
+const lua = require('../src/lua.js');
+const lauxlib = require('../src/lauxlib.js');
+const lualib = require('../src/lualib.js');
+const {to_luastring} = require("../src/fengaricore.js");
+
+test('luaL_loadstring', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local a = "hello world"
+ return a
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe("hello world");
+});
+
+
+test('load', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local f = load("return 'js running lua running lua'")
+ return f()
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe("js running lua running lua");
+});
+
+
+test('luaL_loadbuffer', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local a = "hello world"
+ return a
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ let bc = toByteCode(luaCode);
+ lauxlib.luaL_loadbuffer(L, bc, null, to_luastring("test"));
+ lua.lua_call(L, 0, -1);
+ }
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe("hello world");
+});
+
+// TODO: test stdin
+test('loadfile', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local f = assert(loadfile("test/loadfile-test.lua"))
+ return f()
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe("hello world");
+});
+
+
+test('loadfile (binary)', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local f = assert(loadfile("test/loadfile-test.bc"))
+ return f()
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe("hello world");
+});
+
+
+test('dofile', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return dofile("test/loadfile-test.lua")
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+ expect(lua.lua_tojsstring(L, -1))
+ .toBe("hello world");
+});
diff --git a/tests/loadfile-test.bc b/test/loadfile-test.bc
index f0e98da..f0e98da 100644
--- a/tests/loadfile-test.bc
+++ b/test/loadfile-test.bc
Binary files differ
diff --git a/tests/loadfile-test.lua b/test/loadfile-test.lua
index 838d20b..838d20b 100644
--- a/tests/loadfile-test.lua
+++ b/test/loadfile-test.lua
diff --git a/test/loadlib.test.js b/test/loadlib.test.js
new file mode 100644
index 0000000..c0125c0
--- /dev/null
+++ b/test/loadlib.test.js
@@ -0,0 +1,73 @@
+"use strict";
+
+const lua = require('../src/lua.js');
+const lauxlib = require('../src/lauxlib.js');
+const lualib = require('../src/lualib.js');
+const {to_luastring} = require("../src/fengaricore.js");
+
+test('require an existing module', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return require('os')
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_istable(L, -1)).toBe(true);
+});
+
+
+test('require a file', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return require('test.module-hello')()
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello from module");
+});
+
+
+test('package.loadlib', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return package.loadlib('./test/lib-hello.js.mod', 'hello')()
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello from js lib");
+});
+
+
+test('package.searchpath', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return package.searchpath('module-hello', './?.lua;./test/?.lua')
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toBe("./test/module-hello.lua");
+});
diff --git a/test/loslib.test.js b/test/loslib.test.js
new file mode 100644
index 0000000..a270d49
--- /dev/null
+++ b/test/loslib.test.js
@@ -0,0 +1,101 @@
+"use strict";
+
+const lua = require('../src/lua.js');
+const lauxlib = require('../src/lauxlib.js');
+const lualib = require('../src/lualib.js');
+const {to_luastring} = require("../src/fengaricore.js");
+
+test('os.time', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return os.time()
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_isinteger(L, -1)).toBe(true);
+});
+
+
+test('os.time (with format)', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return os.time({
+ day = 8,
+ month = 2,
+ year = 2015
+ })
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tointeger(L, -1))
+ .toBe(new Date(2015, 1, 8, 12, 0, 0, 0).getTime() / 1000);
+});
+
+
+test('os.difftime', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local t1 = os.time()
+ local t2 = os.time()
+ return os.difftime(t2, t1)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_isnumber(L, -1)).toBe(true);
+});
+
+
+test('os.date', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return os.date('%Y-%m-%d', os.time({
+ day = 8,
+ month = 2,
+ year = 2015
+ }))
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toBe("2015-02-08");
+});
+
+
+test('os.getenv', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return os.getenv('PATH')
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_isstring(L, -1)).toBe(true);
+});
diff --git a/test/lstrlib.test.js b/test/lstrlib.test.js
new file mode 100644
index 0000000..70db9e2
--- /dev/null
+++ b/test/lstrlib.test.js
@@ -0,0 +1,433 @@
+"use strict";
+
+const lua = require('../src/lua.js');
+const lauxlib = require('../src/lauxlib.js');
+const lualib = require('../src/lualib.js');
+const {to_luastring} = require("../src/fengaricore.js");
+
+test('string.len', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local a = "world"
+ return string.len("hello"), a:len()
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tointeger(L, -2)).toBe(5);
+ expect(lua.lua_tointeger(L, -1)).toBe(5);
+});
+
+
+test('string.char', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return string.char(104, 101, 108, 108, 111)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello");
+});
+
+
+test('string.upper, string.lower', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return string.upper("hello"), string.lower("HELLO")
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -2)).toBe("HELLO");
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello");
+});
+
+
+test('string.rep', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return string.rep("hello", 3, ", ")
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello, hello, hello");
+});
+
+
+test('string.reverse', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return string.reverse("olleh")
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello");
+});
+
+
+test('string.byte', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return string.byte("hello", 2, 4)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tointeger(L, -3)).toBe(101);
+ expect(lua.lua_tointeger(L, -2)).toBe(108);
+ expect(lua.lua_tointeger(L, -1)).toBe(108);
+});
+
+
+test('string.format', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return string.format("%%%d %010d", 10, 23)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toBe("%10 0000000023");
+});
+
+
+test('string.format', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return string.format("%07X", 0xFFFFFFF)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toBe("FFFFFFF");
+});
+
+
+test('string.format', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return string.format("%q", 'a string with "quotes" and \\n new line')
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toBe('"a string with \\"quotes\\" and \\\n new line"',
+ "Correct element(s) on the stack"
+ );
+});
+
+
+test('string.sub', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return string.sub("123456789",2,4), -- "234"
+ string.sub("123456789",7), -- "789"
+ string.sub("123456789",7,6), -- ""
+ string.sub("123456789",7,7), -- "7"
+ string.sub("123456789",0,0), -- ""
+ string.sub("123456789",-10,10), -- "123456789"
+ string.sub("123456789",1,9), -- "123456789"
+ string.sub("123456789",-10,-20), -- ""
+ string.sub("123456789",-1), -- "9"
+ string.sub("123456789",-4), -- "6789"
+ string.sub("123456789",-6, -4) -- "456"
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -11)).toBe("234");
+ expect(lua.lua_tojsstring(L, -10)).toBe("789");
+ expect(lua.lua_tojsstring(L, -9)).toBe("");
+ expect(lua.lua_tojsstring(L, -8)).toBe("7");
+ expect(lua.lua_tojsstring(L, -7)).toBe("");
+ expect(lua.lua_tojsstring(L, -6)).toBe("123456789");
+ expect(lua.lua_tojsstring(L, -5)).toBe("123456789");
+ expect(lua.lua_tojsstring(L, -4)).toBe("");
+ expect(lua.lua_tojsstring(L, -3)).toBe("9");
+ expect(lua.lua_tojsstring(L, -2)).toBe("6789");
+ expect(lua.lua_tojsstring(L, -1)).toBe("456");
+});
+
+
+test('string.dump', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local todump = function()
+ local s = "hello"
+ local i = 12
+ local f = 12.5
+ local b = true
+
+ return s .. i .. f
+ end
+
+ return string.dump(todump)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ lauxlib.luaL_loadstring(L, to_luastring(luaCode.trim()));
+ lua.lua_call(L, 0, -1);
+ let str = lua.lua_tostring(L, -1);
+ lua.lua_load(L, function(L, s) {
+ let r = s.str;
+ s.str = null;
+ return r;
+ }, {str: str}, to_luastring("test"), to_luastring("binary"));
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello1212.5");
+});
+
+
+test('string.pack/unpack/packsize', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local s1, n, s2 = "hello", 2, "you"
+ local packed = string.pack("c5jc3", s1, n, s2)
+ local us1, un, us2 = string.unpack("c5jc3", packed)
+ return string.packsize("c5jc3"), s1 == us1 and n == un and s2 == us2
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tointeger(L, -2)).toBe(12);
+ expect(lua.lua_toboolean(L, -1)).toBe(true);
+});
+
+
+test('string.find without pattern', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return string.find("hello to you", " to ")
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tointeger(L, -2)).toBe(6);
+ expect(lua.lua_tointeger(L, -1)).toBe(9);
+});
+
+
+test('string.match', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return string.match("foo: 123 bar: 456", "(%a+):%s*(%d+)")
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -2)).toBe("foo");
+ expect(lua.lua_tojsstring(L, -1)).toBe("123");
+});
+
+
+test('string.find', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return string.find("foo: 123 bar: 456", "(%a+):%s*(%d+)")
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tointeger(L, -4)).toBe(1);
+ expect(lua.lua_tointeger(L, -3)).toBe(8);
+ expect(lua.lua_tojsstring(L, -2)).toBe("foo");
+ expect(lua.lua_tojsstring(L, -1)).toBe("123");
+});
+
+
+test('string.gmatch', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local s = "hello world from Lua"
+ local t = {}
+
+ for w in string.gmatch(s, "%a+") do
+ table.insert(t, w)
+ end
+
+ return table.unpack(t)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -4)).toBe("hello");
+ expect(lua.lua_tojsstring(L, -3)).toBe("world");
+ expect(lua.lua_tojsstring(L, -2)).toBe("from");
+ expect(lua.lua_tojsstring(L, -1)).toBe("Lua");
+});
+
+
+test('string.gsub', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return string.gsub("hello world", "(%w+)", "%1 %1")
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -2)).toBe("hello hello world world");
+ expect(lua.lua_tointeger(L, -1)).toBe(2);
+});
+
+
+test('string.gsub (number)', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return string.gsub("hello world", "%w+", "%0 %0", 1)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -2)).toBe("hello hello world");
+ expect(lua.lua_tointeger(L, -1)).toBe(1);
+});
+
+
+test('string.gsub (pattern)', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return string.gsub("hello world from Lua", "(%w+)%s*(%w+)", "%2 %1")
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -2)).toBe("world hello Lua from");
+ expect(lua.lua_tointeger(L, -1)).toBe(2);
+});
+
+
+test('string.gsub (function)', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return string.gsub("4+5 = $return 4+5$", "%$(.-)%$", function (s)
+ return load(s)()
+ end)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -2)).toBe("4+5 = 9");
+ expect(lua.lua_tointeger(L, -1)).toBe(1);
+});
+
+
+
+test('string.gsub (table)', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local t = {name="lua", version="5.3"}
+ return string.gsub("$name-$version.tar.gz", "%$(%w+)", t)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -2)).toBe("lua-5.3.tar.gz");
+ expect(lua.lua_tointeger(L, -1)).toBe(2);
+});
diff --git a/test/ltablib.test.js b/test/ltablib.test.js
new file mode 100644
index 0000000..2cce118
--- /dev/null
+++ b/test/ltablib.test.js
@@ -0,0 +1,183 @@
+"use strict";
+
+const lua = require('../src/lua.js');
+const lauxlib = require('../src/lauxlib.js');
+const lualib = require('../src/lualib.js');
+const {to_luastring} = require("../src/fengaricore.js");
+
+const inttable2array = function(t) {
+ let a = [];
+ t.strong.forEach(function (v, k) {
+ if (v.key.ttisnumber())
+ a[k - 1] = v.value;
+ });
+ return a.map(e => e.value);
+};
+
+test('table.concat', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return table.concat({1, 2, 3, 4, 5, 6, 7}, ",", 3, 5)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toBe("3,4,5");
+});
+
+
+test('table.pack', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return table.pack(1, 2, 3)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect([...lua.lua_topointer(L, -1).strong.entries()]
+ .filter(e => e[1].key.ttisnumber()) // Filter out the 'n' field
+ .map(e => e[1].value.value).reverse()
+ ).toEqual([1, 2, 3]);
+});
+
+
+test('table.unpack', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return table.unpack({1, 2, 3, 4, 5}, 2, 4)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tointeger(L, -3)).toBe(2);
+ expect(lua.lua_tointeger(L, -2)).toBe(3);
+ expect(lua.lua_tointeger(L, -1)).toBe(4);
+});
+
+
+test('table.insert', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local t = {1, 3, 4}
+ table.insert(t, 5)
+ table.insert(t, 2, 2)
+ return t
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(
+ [...lua.lua_topointer(L, -1).strong.entries()]
+ .filter(e => e[1].key.ttisnumber())
+ .map(e => e[1].value.value).sort()
+ ).toEqual([1, 2, 3, 4, 5]);
+});
+
+
+test('table.remove', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local t = {1, 2, 3, 3, 4, 4}
+ table.remove(t)
+ table.remove(t, 3)
+ return t
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(
+ [...lua.lua_topointer(L, -1).strong.entries()]
+ .filter(e => e[1].key.ttisnumber())
+ .map(e => e[1].value.value).sort()
+ ).toEqual([1, 2, 3, 4]);
+});
+
+
+test('table.move', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local t1 = {3, 4, 5}
+ local t2 = {1, 2, nil, nil, nil, 6}
+ return table.move(t1, 1, #t1, 3, t2)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(
+ [...lua.lua_topointer(L, -1).strong.entries()]
+ .filter(e => e[1].key.ttisnumber())
+ .map(e => e[1].value.value).sort()
+ ).toEqual([1, 2, 3, 4, 5, 6]);
+});
+
+
+test('table.sort (<)', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local t = {3, 1, 5, ['just'] = 'tofuckitup', 2, 4}
+ table.sort(t)
+ return t
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(inttable2array(lua.lua_topointer(L, -1)))
+ .toEqual([1, 2, 3, 4, 5]);
+});
+
+
+test('table.sort with cmp function', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local t = {3, 1, 5, ['just'] = 'tofuckitup', 2, 4}
+ table.sort(t, function (a, b)
+ return a > b
+ end)
+ return t
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(inttable2array(lua.lua_topointer(L, -1)))
+ .toEqual([5, 4, 3, 2, 1]);
+});
diff --git a/test/ltm.test.js b/test/ltm.test.js
new file mode 100644
index 0000000..c4e03da
--- /dev/null
+++ b/test/ltm.test.js
@@ -0,0 +1,559 @@
+"use strict";
+
+const lua = require('../src/lua.js');
+const lauxlib = require('../src/lauxlib.js');
+const lualib = require('../src/lualib.js');
+const {to_luastring} = require("../src/fengaricore.js");
+
+test('__index, __newindex: with actual table', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local t = {yo=1}
+ return t.yo, t.lo
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_isnil(L, -1)).toBe(true);
+ expect(lua.lua_tointeger(L, -2)).toBe(1);
+});
+
+
+test('__newindex: with non table', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local t = "a string"
+ t.yo = "hello"
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ }
+
+ expect(() => {
+ lua.lua_call(L, 0, -1);
+ }).toThrow();
+});
+
+
+test('__index function in metatable', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local mt = {
+ __index = function (table, key)
+ return "__index"
+ end
+ }
+
+ local t = {}
+
+ setmetatable(t, mt)
+
+ return t.yo
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toBe("__index");
+});
+
+
+test('__newindex function in metatable', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local mt = {
+ __newindex = function (table, key, value)
+ return "__newindex"
+ end
+ }
+
+ local t = {}
+
+ setmetatable(t, mt)
+
+ t.yo = "hello"
+
+ return t.yo
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_isnil(L, -1)).toBe(true);
+});
+
+
+test('__index table in metatable', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local mmt = {
+ yo = "hello"
+ }
+
+ local mt = {
+ __index = mmt
+ }
+
+ local t = {}
+
+ setmetatable(t, mt)
+
+ return t.yo
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello");
+});
+
+
+test('__newindex table in metatable', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local mmt = {
+ yo = "hello"
+ }
+
+ local mt = {
+ __newindex = mmt
+ }
+
+ local t = {}
+
+ setmetatable(t, mt)
+
+ t.yo = "world"
+
+ return t.yo, mmt.yo
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toBe("world");
+ expect(lua.lua_isnil(L, -2)).toBe(true);
+});
+
+
+test('__index table with own metatable', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local mmmt = {
+ __index = function (t, k)
+ return "hello"
+ end
+ }
+
+ local mmt = {
+ yoo = "bye"
+ }
+
+ setmetatable(mmt, mmmt)
+
+ local mt = {
+ __index = mmt
+ }
+
+ local t = {}
+
+ setmetatable(t, mt)
+
+ return t.yo
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello");
+});
+
+
+test('__newindex table with own metatable', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local up = nil
+
+ local mmmt = {
+ __newindex = function (t, k, v)
+ up = v
+ end
+ }
+
+ local mmt = {}
+
+ setmetatable(mmt, mmmt)
+
+ local mt = {
+ __newindex = mmt
+ }
+
+ setmetatable(mt, mmt)
+
+ local t = {}
+
+ setmetatable(t, mt)
+
+ t.yo = "hello"
+
+ return t.yo, up
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello");
+ expect(lua.lua_isnil(L, -2)).toBe(true);
+});
+
+
+test('binary __xxx functions in metatable', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local mt = {
+ __add = function (a, b)
+ return "{} + " .. b
+ end,
+
+ __sub = function (a, b)
+ return "{} - " .. b
+ end,
+
+ __mul = function (a, b)
+ return "{} * " .. b
+ end,
+
+ __mod = function (a, b)
+ return "{} % " .. b
+ end,
+
+ __pow = function (a, b)
+ return "{} ^ " .. b
+ end,
+
+ __div = function (a, b)
+ return "{} / " .. b
+ end,
+
+ __idiv = function (a, b)
+ return "{} // " .. b
+ end,
+
+ __band = function (a, b)
+ return "{} & " .. b
+ end,
+
+ __bor = function (a, b)
+ return "{} | " .. b
+ end,
+
+ __bxor = function (a, b)
+ return "{} ~ " .. b
+ end,
+
+ __shl = function (a, b)
+ return "{} << " .. b
+ end,
+
+ __shr = function (a, b)
+ return "{} >> " .. b
+ end
+
+ }
+
+ local t = {}
+
+ setmetatable(t, mt)
+
+ return
+ t + 1,
+ t - 1,
+ t * 1,
+ t % 1,
+ t ^ 1,
+ t / 1,
+ t // 1,
+ t & 1,
+ t | 1,
+ t ~ 1,
+ t << 1,
+ t >> 1
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(L.stack.slice(L.top - 12, L.top).map(e => e.jsstring()))
+ .toEqual([
+ "{} + 1",
+ "{} - 1",
+ "{} * 1",
+ "{} % 1",
+ "{} ^ 1",
+ "{} / 1",
+ "{} // 1",
+ "{} & 1",
+ "{} | 1",
+ "{} ~ 1",
+ "{} << 1",
+ "{} >> 1"
+ ]);
+});
+
+
+test('__eq', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local mt = {
+ __eq = function (a, b)
+ return true
+ end
+ }
+
+ local t = {}
+
+ setmetatable(t, mt)
+
+ return t == {}
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_toboolean(L, -1)).toBe(true);
+});
+
+
+test('__lt', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local mt = {
+ __lt = function (a, b)
+ return true
+ end
+ }
+
+ local t = {}
+
+ setmetatable(t, mt)
+
+ return t < {}
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_toboolean(L, -1)).toBe(true);
+});
+
+
+test('__le', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local mt = {
+ __le = function (a, b)
+ return true
+ end
+ }
+
+ local t = {}
+
+ setmetatable(t, mt)
+
+ return t <= {}
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_toboolean(L, -1)).toBe(true);
+});
+
+
+test('__le that uses __lt', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local mt = {
+ __lt = function (a, b)
+ return false
+ end
+ }
+
+ local t = {}
+
+ setmetatable(t, mt)
+
+ return {} <= t
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_toboolean(L, -1)).toBe(true);
+});
+
+
+test('__unm, __bnot', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local mt = {
+ __unm = function (a)
+ return "hello"
+ end,
+
+ __bnot = function (a)
+ return "world"
+ end
+ }
+
+ local t = {}
+
+ setmetatable(t, mt)
+
+ return -t, ~t
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toBe("world");
+ expect(lua.lua_tojsstring(L, -2)).toBe("hello");
+});
+
+
+test('__len', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local mt = {
+ __len = function (a)
+ return "hello"
+ end
+ }
+
+ local t = {}
+
+ setmetatable(t, mt)
+
+ return #t
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello");
+});
+
+
+test('__concat', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local mt = {
+ __concat = function (a)
+ return "hello"
+ end
+ }
+
+ local t = {}
+
+ setmetatable(t, mt)
+
+ return t .. " world"
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello");
+});
+
+
+test('__call', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local mt = {
+ __call = function (a, ...)
+ return "hello", ...
+ end
+ }
+
+ local t = {}
+
+ setmetatable(t, mt)
+
+ return t("world","wow")
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(L.stack.slice(L.top - 3, L.top).map(e => e.jsstring()))
+ .toEqual(["hello", "world", "wow"]);
+});
diff --git a/test/lua.test.js b/test/lua.test.js
new file mode 100644
index 0000000..fc26749
--- /dev/null
+++ b/test/lua.test.js
@@ -0,0 +1,55 @@
+"use strict";
+
+const lua = require('../src/lua.js');
+const lauxlib = require('../src/lauxlib.js');
+const lualib = require('../src/lualib.js');
+const {to_luastring} = require("../src/fengaricore.js");
+
+// TODO: remove
+test.skip('locals.lua', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ _soft = true
+ require = function(lib) return _G[lib] end -- NYI
+ return dofile("tests/lua-tests/locals.lua")
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+});
+
+
+test.skip('constructs.lua', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ _soft = true
+ require = function(lib) return _G[lib] end -- NYI
+ return dofile("tests/lua-tests/constructs.lua")
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+});
+
+
+test.skip('strings.lua', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return dofile("tests/lua-tests/strings.lua")
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+});
diff --git a/test/lutf8lib.test.js b/test/lutf8lib.test.js
new file mode 100644
index 0000000..d2d51b3
--- /dev/null
+++ b/test/lutf8lib.test.js
@@ -0,0 +1,97 @@
+"use strict";
+
+const lua = require("../src/lua.js");
+const lauxlib = require("../src/lauxlib.js");
+const lualib = require("../src/lualib.js");
+const {to_luastring} = require("../src/fengaricore.js");
+
+test('utf8.offset', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return utf8.offset("( ͡° ͜ʖ ͡° )", 5)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tointeger(L, -1)).toBe(7);
+});
+
+
+test('utf8.codepoint', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return utf8.codepoint("( ͡° ͜ʖ ͡° )", 5, 8)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tointeger(L, -3)).toBe(176);
+ expect(lua.lua_tointeger(L, -2)).toBe(32);
+ expect(lua.lua_tointeger(L, -1)).toBe(860);
+});
+
+
+test('utf8.char', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return utf8.char(40, 32, 865, 176, 32, 860, 662, 32, 865, 176, 32, 41)
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toBe("( ͡° ͜ʖ ͡° )");
+});
+
+
+test('utf8.len', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ return utf8.len("( ͡° ͜ʖ ͡° )")
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tointeger(L, -1)).toBe(12);
+});
+
+
+test('utf8.codes', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ let luaCode = `
+ local s = "( ͡° ͜ʖ ͡° )"
+ local results = ""
+ for p, c in utf8.codes(s) do
+ results = results .. "[" .. p .. "," .. c .. "] "
+ end
+ return results
+ `;
+ {
+ lualib.luaL_openlibs(L);
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
+ lua.lua_call(L, 0, -1);
+ }
+
+ expect(lua.lua_tojsstring(L, -1)).toBe("[1,40] [2,32] [3,865] [5,176] [7,32] [8,860] [10,662] [12,32] [13,865] [15,176] [17,32] [18,41] ");
+});
diff --git a/tests/lvm.js b/test/lvm.test.js
index 7fba553..daa4539 100644
--- a/tests/lvm.js
+++ b/test/lvm.test.js
@@ -1,120 +1,104 @@
"use strict";
-const test = require('tape');
-
-const lua = require("../src/lua.js");
-const lstring = require("../src/lstring.js");
+const lua = require("../src/lua.js");
+const lauxlib = require("../src/lauxlib.js");
+const lstring = require("../src/lstring.js");
const {to_luastring} = require("../src/fengaricore.js");
-const getState = require("./tests.js").getState;
-test('LOADK, RETURN', function (t) {
+test('LOADK, RETURN', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = "hello world"
return a
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello world",
- "Program output is correct"
- );
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello world");
});
-test('MOVE', function (t) {
+test('MOVE', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = "hello world"
local b = a
return b
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello world",
- "Program output is correct"
- );
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello world");
});
-test('Binary op', function (t) {
+test('Binary op', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = 5
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 () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.deepEqual(
- L.stack.slice(L.top - 12, L.top).map(e => e.value),
- [15, -5, 50, 0.5, 5, 9765625.0, 0, 0, 15, 15, 5120, 0],
- "Program output is correct"
- );
+ expect(L.stack.slice(L.top - 12, L.top).map(e => e.value))
+ .toEqual([15, -5, 50, 0.5, 5, 9765625.0, 0, 0, 15, 15, 5120, 0]);
});
-test('Unary op, LOADBOOL', function (t) {
+test('Unary op, LOADBOOL', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = 5
local b = false
return -a, not b, ~a
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.deepEqual(
- L.stack.slice(L.top - 3, L.top).map(e => e.value),
- [-5, true, -6],
- "Program output is correct"
- );
+ expect(L.stack.slice(L.top - 3, L.top).map(e => e.value))
+ .toEqual([-5, true, -6]);
});
-test('NEWTABLE', function (t) {
+test('NEWTABLE', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = {}
return a
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.ok(
- L.stack[L.top - 1].ttistable(),
- "Program output is correct"
- );
+ expect(lua.lua_istable(L, -1)).toBe(true);
});
-test('CALL', function (t) {
+test('CALL', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local f = function (a, b)
return a + b
@@ -123,24 +107,20 @@ test('CALL', function (t) {
local c = f(1, 2)
return c
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 3,
- "Program output is correct"
- );
+ expect(lua.lua_tointeger(L, -1)).toBe(3);
});
-test('Multiple return', function (t) {
+test('Multiple return', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local f = function (a, b)
return a + b, a - b, a * b
@@ -153,184 +133,154 @@ test('Multiple return', function (t) {
c, d, e = f(1,2)
return c, d, e
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.deepEqual(
- L.stack.slice(L.top - 3, L.top).map(e => e.value),
- [3, -1, 2],
- "Program output is correct"
- );
+ expect(L.stack.slice(L.top - 3, L.top).map(e => e.value))
+ .toEqual([3, -1, 2]);
});
-test('TAILCALL', function (t) {
+test('TAILCALL', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local f = function (a, b)
return a + b
end
return f(1,2)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 3,
- "Program output is correct"
- );
+ expect(lua.lua_tointeger(L, -1)).toBe(3);
});
-test('VARARG', function (t) {
+test('VARARG', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local f = function (...)
return ...
end
return f(1,2,3)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.deepEqual(
- L.stack.slice(L.top - 3, L.top).map(e => e.value),
- [1, 2, 3],
- "Program output is correct"
- );
+ expect(L.stack.slice(L.top - 3, L.top).map(e => e.value))
+ .toEqual([1, 2, 3]);
});
-test('LE, JMP', function (t) {
+test('LE, JMP', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a, b = 1, 1
return a >= b
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.strictEqual(
- lua.lua_toboolean(L, -1),
- true,
- "Program output is correct"
- );
+ expect(lua.lua_toboolean(L, -1)).toBe(true);
});
-test('LT', function (t) {
+test('LT', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a, b = 1, 1
return a > b
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.strictEqual(
- lua.lua_toboolean(L, -1),
- false,
- "Program output is correct"
- );
+ expect(lua.lua_toboolean(L, -1)).toBe(false);
});
-test('EQ', function (t) {
+test('EQ', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a, b = 1, 1
return a == b
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.strictEqual(
- lua.lua_toboolean(L, -1),
- true,
- "Program output is correct"
- );
+ expect(lua.lua_toboolean(L, -1)).toBe(true);
});
-test('TESTSET (and)', function (t) {
+test('TESTSET (and)', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = true
local b = "hello"
return a and b
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello",
- "Program output is correct"
- );
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello");
});
-test('TESTSET (or)', function (t) {
+test('TESTSET (or)', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = false
local b = "hello"
return a or b
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello",
- "Program output is correct"
- );
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello");
});
-test('TEST (true)', function (t) {
+test('TEST (true)', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = true
local b = "hello"
@@ -340,24 +290,20 @@ test('TEST (true)', function (t) {
end
return "goodbye"
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello",
- "Program output is correct"
- );
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello");
});
-test('TEST (false)', function (t) {
+test('TEST (false)', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = false
local b = "hello"
@@ -367,24 +313,20 @@ test('TEST (false)', function (t) {
end
return "goodbye"
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "goodbye",
- "Program output is correct"
- );
+ expect(lua.lua_tojsstring(L, -1)).toBe("goodbye");
});
-test('FORPREP, FORLOOP (int)', function (t) {
+test('FORPREP, FORLOOP (int)', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local total = 0
@@ -393,24 +335,20 @@ test('FORPREP, FORLOOP (int)', function (t) {
end
return total
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 55,
- "Program output is correct"
- );
+ expect(lua.lua_tointeger(L, -1)).toBe(55);
});
-test('FORPREP, FORLOOP (float)', function (t) {
+test('FORPREP, FORLOOP (float)', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local total = 0
@@ -419,24 +357,20 @@ test('FORPREP, FORLOOP (float)', function (t) {
end
return total
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.strictEqual(
- lua.lua_tonumber(L, -1),
- 60.5,
- "Program output is correct"
- );
+ expect(lua.lua_tonumber(L, -1)).toBe(60.5);
});
-test('SETTABLE, GETTABLE', function (t) {
+test('SETTABLE, GETTABLE', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local t = {}
@@ -444,30 +378,23 @@ test('SETTABLE, GETTABLE', function (t) {
t["two"] = "world"
return t
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
-
- t.deepEqual(
- L.stack[L.top - 1].value.strong.get(1).value.jsstring(),
- "hello",
- "Program output is correct"
- );
-
- t.deepEqual(
- L.stack[L.top - 1].value.strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring(), // "two"
- "world",
- "Program output is correct"
- );
+ }
+
+ expect(lua.lua_topointer(L, -1).strong.get(1).value.jsstring())
+ .toBe("hello");
+ expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring())
+ .toBe("world");
});
-test('SETUPVAL, GETUPVAL', function (t) {
+test('SETUPVAL, GETUPVAL', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local up = "hello"
@@ -478,24 +405,20 @@ test('SETUPVAL, GETUPVAL', function (t) {
end
return f()
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "world",
- "Program output is correct"
- );
+ expect(lua.lua_tojsstring(L, -1)).toBe("world");
});
-test('SETTABUP, GETTABUP', function (t) {
+test('SETTABUP, GETTABUP', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
t = {}
@@ -503,30 +426,23 @@ test('SETTABUP, GETTABUP', function (t) {
t["two"] = "world"
return t
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
-
- t.deepEqual(
- L.stack[L.top - 1].value.strong.get(1).value.jsstring(),
- "hello", // "hello"
- "Program output is correct"
- );
-
- t.deepEqual(
- L.stack[L.top - 1].value.strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring(), // "two"
- "world", // "world"
- "Program output is correct"
- );
+ }
+
+ expect(lua.lua_topointer(L, -1).strong.get(1).value.jsstring())
+ .toBe("hello");
+ expect(lua.lua_topointer(L, -1).strong.get(lstring.luaS_hash(to_luastring("two"))).value.jsstring())
+ .toBe("world");
});
-test('SELF', function (t) {
+test('SELF', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local t = {}
@@ -536,46 +452,39 @@ test('SELF', function (t) {
end
return t:get()
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello",
- "Program output is correct"
- );
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello");
});
-test('SETLIST', function (t) {
+test('SETLIST', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local t = {1, 2, 3, 4, 5, 6, 7, 8, 9}
return t
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.deepEqual(
- [...L.stack[L.top - 1].value.strong.entries()].map(e => e[1].value.value).reverse(),
- [1, 2, 3, 4, 5, 6, 7, 8, 9],
- "Program output is correct"
- );
+ expect([...lua.lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).reverse())
+ .toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9]);
});
-test('Variable SETLIST', function (t) {
+test('Variable SETLIST', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = function ()
return 6, 7, 8, 9
@@ -584,42 +493,33 @@ test('Variable SETLIST', function (t) {
local t = {1, 2, 3, 4, 5, a()}
return t
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.deepEqual(
- [...L.stack[L.top - 1].value.strong.entries()].map(e => e[1].value.value).reverse(),
- [1, 2, 3, 4, 5, 6, 7, 8, 9],
- "Program output is correct"
- );
+ expect([...lua.lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).reverse())
+ .toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9]);
});
-test('Long SETLIST', function (t) {
+test('Long SETLIST', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local t = {1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5}
return t
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.deepEqual(
- [...L.stack[L.top - 1].value.strong.entries()].map(e => e[1].value.value).reverse(),
- [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],
- "Program output is correct"
- );
+ expect([...lua.lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).reverse())
+ .toEqual([1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]);
});
@@ -640,14 +540,17 @@ test('Long SETLIST', function (t) {
// // }, "Program executed without errors");
//
// t.deepEqual(
-// [...L.stack[L.top - 1].value.strong.entries()].map(e => e[1].value.value).reverse(),
+// [...lua.lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).reverse(),
// [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4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, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],
// "Program output is correct"
// );
// });
-test('TFORCALL, TFORLOOP', function (t) {
+test('TFORCALL, TFORLOOP', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local iterator = function (t, i)
i = i + 1
@@ -668,74 +571,49 @@ test('TFORCALL, TFORLOOP', function (t) {
end
return r
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 6,
- "Program output is correct"
- );
+ expect(lua.lua_tointeger(L, -1)).toBe(6);
});
-test('LEN', function (t) {
+test('LEN', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local t = {[10000] = "foo"}
local t2 = {1, 2, 3}
local s = "hello"
return #t, #t2, #s
- `, L;
-
- t.plan(4);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
-
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 5,
- "Program output is correct"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -2),
- 3,
- "Program output is correct"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -3),
- 0,
- "Program output is correct"
- );
+ }
+
+ expect(lua.lua_tointeger(L, -1)).toBe(5);
+ expect(lua.lua_tointeger(L, -2)).toBe(3);
+ expect(lua.lua_tointeger(L, -3)).toBe(0);
});
-test('CONCAT', function (t) {
+test('CONCAT', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
return "hello " .. 2 .. " you"
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = getState(luaCode);
+ `;
+ {
+ expect(lauxlib.luaL_loadstring(L, to_luastring(luaCode))).toBe(lua.LUA_OK);
lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
+ }
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello 2 you",
- "Program output is correct"
- );
+ expect(lua.lua_tojsstring(L, -1)).toBe("hello 2 you");
});
diff --git a/tests/manual-tests/debug-cli.js b/test/manual-tests/debug-cli.js
index dc49a0e..dc49a0e 100755
--- a/tests/manual-tests/debug-cli.js
+++ b/test/manual-tests/debug-cli.js
diff --git a/tests/module-hello.lua b/test/module-hello.lua
index 4de5890..4de5890 100644
--- a/tests/module-hello.lua
+++ b/test/module-hello.lua
diff --git a/tests/test-suite/api.js b/test/test-suite/api.test.js
index 0061c88..5a5e10e 100644
--- a/tests/test-suite/api.js
+++ b/test/test-suite/api.test.js
@@ -1,13 +1,11 @@
"use strict";
-const test = require('tape');
-
-const lua = require('../../src/lua.js');
+const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
-const lualib = require('../../src/lualib.js');
+const lualib = require('../../src/lualib.js');
const {to_luastring} = require("../../src/fengaricore.js");
-const ltests = require('./ltests.js');
+const ltests = require('./ltests.js');
// TODO: a lot of gc related tests are skipped
// TODO: io.read is used in several tests, uncomment them when it's implemented
@@ -28,65 +26,44 @@ const prefix = `
end
`;
-test("[test-suite] api: registry", function (t) {
+test("[test-suite] api: registry", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
a = T.testC("pushvalue R; return 1")
assert(a == debug.getregistry())
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: absindex", function (t) {
+test("[test-suite] api: absindex", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(T.testC("settop 10; absindex -1; return 1") == 10)
assert(T.testC("settop 5; absindex -5; return 1") == 1)
assert(T.testC("settop 10; absindex 1; return 1") == 1)
assert(T.testC("settop 10; absindex R; return 1") < -10)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing alignment", function (t) {
+test("[test-suite] api: testing alignment", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
-- Useless tests in fengari since we do the same thing in d2s than in string.pack
a = T.d2s(12458954321123.0)
@@ -99,31 +76,19 @@ test("[test-suite] api: testing alignment", function (t) {
f = T.makeCfunc("pushnum 1; pushnum 2; pushnum 3; return 2")
a,b,c = f()
assert(a == 2 and b == 3 and not c)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: test that all trues are equal", function (t) {
+test("[test-suite] api: test that all trues are equal", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
a,b,c = T.testC("pushbool 1; pushbool 2; pushbool 0; return 3")
assert(a == b and a == true and c == false)
@@ -164,31 +129,19 @@ test("[test-suite] api: test that all trues are equal", function (t) {
t = pack(T.testC("copy -3 -1; return *", 2, 3, 4, 5))
tcheck(t, {n=4,2,3,4,3})
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing 'rotate'", function (t) {
+test("[test-suite] api: testing 'rotate'", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do -- testing 'rotate'
local t = {10, 20, 30, 40, 50, 60}
@@ -212,31 +165,19 @@ test("[test-suite] api: testing 'rotate'", function (t) {
t = pack(T.testC("rotate 5 -1; return *", 10, 20, 30, 40))
tcheck(t, {10, 20, 30, 40})
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing non-function message handlers", function (t) {
+test("[test-suite] api: testing non-function message handlers", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local f = T.makeCfunc[[
@@ -265,60 +206,36 @@ test("[test-suite] api: testing non-function message handlers", function (t) {
t = pack(T.testC("concat 5; return *", "alo", 2, 3, "joao", 12))
tcheck(t, {n=1,"alo23joao12"})
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing MULTRET", function (t) {
+test("[test-suite] api: testing MULTRET", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
t = pack(T.testC("call 2,-1; return *",
function (a,b) return 1,2,3,4,a,b end, "alo", "joao"))
tcheck(t, {n=6,1,2,3,4,"alo", "joao"})
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: test returning more results than fit in the caller stack", function (t) {
+test("[test-suite] api: test returning more results than fit in the caller stack", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do -- test returning more results than fit in the caller stack
local a = {}
@@ -327,31 +244,19 @@ test("[test-suite] api: test returning more results than fit in the caller stack
table.unpack, a)
assert(b == "10")
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing globals", function (t) {
+test("[test-suite] api: testing globals", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
_G.a = 14; _G.b = "a31"
local a = {T.testC[[
@@ -362,31 +267,19 @@ test("[test-suite] api: testing globals", function (t) {
return *
]]}
assert(a[2] == 14 and a[3] == "a31" and a[4] == nil and _G.a == "a31")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing arith", function (t) {
+test("[test-suite] api: testing arith", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(T.testC("pushnum 10; pushnum 20; arith /; return 1") == 0.5)
assert(T.testC("pushnum 10; pushnum 20; arith -; return 1") == -10)
@@ -420,59 +313,35 @@ test("[test-suite] api: testing arith", function (t) {
assert(T.testC("arith %; return 1", a, c)[1] == 4%-3)
assert(T.testC("arith _; arith +; arith %; return 1", b, a, c)[1] ==
8 % (4 + (-3)*2))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: errors in arithmetic", function (t) {
+test("[test-suite] api: errors in arithmetic", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
checkerr("divide by zero", T.testC, "arith \\\\", 10, 0)
checkerr("%%0", T.testC, "arith %", 10, 0)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing lessthan and lessequal", function (t) {
+test("[test-suite] api: testing lessthan and lessequal", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(T.testC("compare LT 2 5, return 1", 3, 2, 2, 4, 2, 2))
assert(T.testC("compare LE 2 5, return 1", 3, 2, 2, 4, 2, 2))
@@ -481,31 +350,19 @@ test("[test-suite] api: testing lessthan and lessequal", function (t) {
assert(T.testC("compare LT 5 2, return 1", 4, 2, 2, 3, 2, 2))
assert(not T.testC("compare LT 2 -3, return 1", "4", "2", "2", "3", "2", "2"))
assert(not T.testC("compare LT -3 2, return 1", "3", "2", "2", "4", "2", "2"))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: non-valid indices produce false", function (t) {
+test("[test-suite] api: non-valid indices produce false", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(not T.testC("compare LT 1 4, return 1"))
assert(not T.testC("compare LE 9 1, return 1"))
@@ -524,31 +381,19 @@ test("[test-suite] api: non-valid indices produce false", function (t) {
assert(a == 20 and b == false)
a,b = T.testC("compare LE 5 -6, return 2", a1, 2, 2, a1, 2, 20)
assert(a == 20 and b == true)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing length", function (t) {
+test("[test-suite] api: testing length", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local t = setmetatable({x = 20}, {__len = function (t) return t.x end})
a,b,c = T.testC([[
@@ -575,31 +420,19 @@ test("[test-suite] api: testing length", function (t) {
return 2
]], t)
assert(a == print and c == 1)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing __concat", function (t) {
+test("[test-suite] api: testing __concat", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
a = setmetatable({x="u"}, {__concat = function (a,b) return a.x..'.'..b.x end})
x,y = T.testC([[
@@ -617,31 +450,19 @@ test("[test-suite] api: testing __concat", function (t) {
-- concat with 1 element
assert(T.testC("concat 1; return 1", "xuxu") == "xuxu")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing lua_is", function (t) {
+test("[test-suite] api: testing lua_is", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
function B(x) return x and 1 or 0 end
@@ -672,31 +493,19 @@ test("[test-suite] api: testing lua_is", function (t) {
assert(count(nil) == 1)
assert(count(io.stdin) == 1)
assert(count(nil, 15) == 100)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing lua_to...", function (t) {
+test("[test-suite] api: testing lua_to...", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
function to (s, x, n)
n = n or 2
@@ -733,30 +542,18 @@ test("[test-suite] api: testing lua_to...", function (t) {
assert(to("func2num", hfunc) ~= 0) -- "heavy" C function (with upvalue)
a = to("tocfunction", math.deg)
assert(a(3) == math.deg(3) and a == math.deg)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing panic function", function (t) {
+test("[test-suite] api: testing panic function", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
-- trivial error
@@ -792,31 +589,19 @@ test("[test-suite] api: testing panic function", function (t) {
end
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing deep JS stack", { skip: true }, function (t) {
+test.skip("[test-suite] api: testing deep JS stack", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
checkerr("XXXX", T.testC, "checkstack 1000023 XXXX") -- too deep
@@ -848,31 +633,19 @@ test("[test-suite] api: testing deep JS stack", { skip: true }, function (t) {
for i = 1,lim do assert(t[i] == i*10); t[i] = nil end
assert(next(t) == nil)
prog, g, t = nil
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing errors", function (t) {
+test("[test-suite] api: testing errors", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
a = T.testC([[
loadstring 2; pcall 0 1 0;
@@ -891,31 +664,19 @@ test("[test-suite] api: testing errors", function (t) {
check3(":1:", T.testC("loadstring 2; return *", "x="))
check3("%.", T.testC("loadfile 2; return *", "."))
check3("xxxx", T.testC("loadfile 2; return *", "xxxx"))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: test errors in non protected threads", { skip: true }, function (t) {
+test("[test-suite] api: test errors in non protected threads", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
function checkerrnopro (code, msg)
local th = coroutine.create(function () end) -- create new thread
@@ -925,35 +686,23 @@ test("[test-suite] api: test errors in non protected threads", { skip: true }, f
if not _soft then
checkerrnopro("pushnum 3; call 0 0", "attempt to call")
- print"testing stack overflow in unprotected thread"
+ -- print"testing stack overflow in unprotected thread"
function f () f() end
checkerrnopro("getglobal 'f'; call 0 0;", "stack overflow")
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing table access", function (t) {
+test("[test-suite] api: testing table access", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do -- getp/setp
local a = {}
@@ -992,31 +741,19 @@ test("[test-suite] api: testing table access", function (t) {
T.testC("settable 2", b, 19)
assert(a[b] == 19)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing getfield/setfield with long keys", function (t) {
+test("[test-suite] api: testing getfield/setfield with long keys", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do -- testing getfield/setfield with long keys
local t = {_012345678901234567890123456789012345678901234567890123456789 = 32}
@@ -1032,31 +769,19 @@ test("[test-suite] api: testing getfield/setfield with long keys", function (t)
assert(_012345678901234567890123456789012345678901234567890123456789 == 33)
_012345678901234567890123456789012345678901234567890123456789 = nil
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing next", function (t) {
+test("[test-suite] api: testing next", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
a = {}
t = pack(T.testC("next; return *", a, nil))
@@ -1066,31 +791,19 @@ test("[test-suite] api: testing next", function (t) {
tcheck(t, {n=3,a,'a',3})
t = pack(T.testC("next; pop 1; next; return *", a, nil))
tcheck(t, {n=1,a})
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing upvalues", function (t) {
+test("[test-suite] api: testing upvalues", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local A = T.testC[[ pushnum 10; pushnum 20; pushcclosure 2; return 1]]
@@ -1106,31 +819,19 @@ test("[test-suite] api: testing upvalues", function (t) {
assert(b.x == 1 and c.x == 2)
-- T.checkmemory()
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing absent upvalues from JS-function pointers", function (t) {
+test("[test-suite] api: testing absent upvalues from JS-function pointers", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(T.testC[[isnull U1; return 1]] == true)
assert(T.testC[[isnull U100; return 1]] == true)
@@ -1142,31 +843,19 @@ test("[test-suite] api: testing absent upvalues from JS-function pointers", func
T.upvalue(f, 3) == nil)
T.upvalue(f, 2, "xuxu")
assert(T.upvalue(f, 2) == "xuxu")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: large closures", function (t) {
+test("[test-suite] api: large closures", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local A = "checkstack 300 msg;" ..
@@ -1179,31 +868,19 @@ test("[test-suite] api: large closures", function (t) {
assert(A("isnull U256; return 1"))
assert(not A("isnil U256; return 1"))
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing get/setuservalue", function (t) {
+test("[test-suite] api: testing get/setuservalue", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
-- bug in 5.1.2
checkerr("got number", debug.setuservalue, 3, {})
@@ -1226,62 +903,38 @@ test("[test-suite] api: testing get/setuservalue", function (t) {
debug.setuservalue(b, 134)
-- collectgarbage() -- number should not be a problem for collector
assert(debug.getuservalue(b) == 134)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing get/setuservalue", { skip: true }, function (t) {
+test.skip("[test-suite] api: testing get/setuservalue", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
T.gcstate("atomic")
assert(T.gccolor(b) == "black")
debug.setuservalue(b, {x = 100})
T.gcstate("pause") -- complete collection
assert(debug.getuservalue(b).x == 100) -- uvalue should be there
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: long chain of userdata", { skip: true }, function (t) {
+test.skip("[test-suite] api: long chain of userdata", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
for i = 1, 1000 do
local bb = T.newuserdata(0)
@@ -1294,31 +947,19 @@ test("[test-suite] api: long chain of userdata", { skip: true }, function (t) {
end
assert(debug.getuservalue(b).x == 100)
b = nil
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: reuse of references", { skip: true }, function (t) {
+test.skip("[test-suite] api: reuse of references", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local i = T.ref{}
T.unref(i)
@@ -1366,31 +1007,19 @@ test("[test-suite] api: reuse of references", { skip: true }, function (t) {
-- collectgarbage()
assert(type(T.getref(a)) == 'table')
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: collect in cl the `val' of all collected userdata", { skip: true }, function (t) {
+test.skip("[test-suite] api: collect in cl the `val' of all collected userdata", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
tt = {}
cl = {n=0}
@@ -1494,31 +1123,19 @@ test("[test-suite] api: collect in cl the `val' of all collected userdata", { sk
for n in pairs(a) do a[n] = nil end
collectgarbage()
assert(#cl == 1 and cl[1] == x) -- old 'x' must be collected
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: test whether udate collection frees memory in the right time", { skip: true }, function (t) {
+test.skip("[test-suite] api: test whether udate collection frees memory in the right time", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
collectgarbage();
@@ -1550,31 +1167,19 @@ test("[test-suite] api: test whether udate collection frees memory in the right
assert(collectgarbage("count") <= x+1)
collectgarbage("restart")
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing lua_equal", function (t) {
+test("[test-suite] api: testing lua_equal", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(T.testC("compare EQ 2 4; return 1", print, 1, print, 20))
assert(T.testC("compare EQ 3 2; return 1", 'alo', "alo"))
@@ -1582,31 +1187,19 @@ test("[test-suite] api: testing lua_equal", function (t) {
assert(not T.testC("compare EQ 2 3; return 1", {}, {}))
assert(not T.testC("compare EQ 2 3; return 1"))
assert(not T.testC("compare EQ 2 3; return 1", 3))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing lua_equal with fallbacks", function (t) {
+test("[test-suite] api: testing lua_equal with fallbacks", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local map = {}
@@ -1624,31 +1217,19 @@ test("[test-suite] api: testing lua_equal with fallbacks", function (t) {
t.__eq = nil
assert(f(10) ~= f(10))
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing changing hooks during hooks", function (t) {
+test("[test-suite] api: testing changing hooks during hooks", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
_G.t = {}
T.sethook([[
@@ -1670,31 +1251,19 @@ test("[test-suite] api: testing changing hooks during hooks", function (t) {
assert(t[3] == "line" and t[4] == line + 1)
assert(t[5] == "line" and t[6] == line + 2)
assert(t[7] == nil)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing errors during GC", { skip: true }, function (t) {
+test.skip("[test-suite] api: testing errors during GC", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do -- testing errors during GC
local a = {}
@@ -1722,31 +1291,19 @@ test("[test-suite] api: testing errors during GC", { skip: true }, function (t)
assert(A == 10) -- number of normal collections
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: test for userdata vals", function (t) {
+test("[test-suite] api: test for userdata vals", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local a = {}; local lim = 30
@@ -1757,31 +1314,19 @@ test("[test-suite] api: test for userdata vals", function (t) {
for i=0,lim do a[T.pushuserdata(i)] = i end
assert(type(tostring(a[1])) == "string")
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing multiple states", function (t) {
+test("[test-suite] api: testing multiple states", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
T.closestate(T.newstate());
L1 = T.newstate()
@@ -1828,58 +1373,31 @@ test("[test-suite] api: testing multiple states", function (t) {
assert(T.doremote(L1, "return a.x") == "1")
T.closestate(L1)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing memory limits", { skip: true }, function (t) {
+test.skip("[test-suite] api: testing memory limits", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
checkerr("block too big", T.newuserdata, math.maxinteger)
collectgarbage()
T.totalmem(T.totalmem()+5000) -- set low memory limit (+5k)
checkerr("not enough memory", load"local a={}; for i=1,100000 do a[i]=i end")
T.totalmem(0) -- restore high limit
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
@@ -1910,61 +1428,40 @@ const memprefix = `
`;
-test("[test-suite] api: testing memory errors when creating a new state", { skip: true }, function (t) {
+test.skip("[test-suite] api: testing memory errors when creating a new state", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
b = testamem("state creation", T.newstate)
T.closestate(b); -- close new state
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: get main thread from registry (at index LUA_RIDX_MAINTHREAD == 1)", function (t) {
+test("[test-suite] api: get main thread from registry (at index LUA_RIDX_MAINTHREAD == 1)", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
mt = T.testC("rawgeti R 1; return 1")
assert(type(mt) == "thread" and coroutine.running() == mt)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: test thread creation after stressing GC", { skip: true }, function (t) {
+test.skip("[test-suite] api: test thread creation after stressing GC", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
function expand (n,s)
if n==0 then return "" end
@@ -1980,60 +1477,36 @@ test("[test-suite] api: test thread creation after stressing GC", { skip: true }
testamem("thread creation", function ()
return T.doonnewstack("x=1") == 0 -- try to create thread
end)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing memory x compiler", { skip: true }, function (t) {
+test.skip("[test-suite] api: testing memory x compiler", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
testamem("loadstring", function ()
return load("x=1") -- try to do load a string
end)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing memory x dofile", { skip: true }, function (t) {
+test.skip("[test-suite] api: testing memory x dofile", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local testprog = [[
local function foo () return end
@@ -2055,31 +1528,19 @@ test("[test-suite] api: testing memory x dofile", { skip: true }, function (t) {
end)
assert(os.remove(t))
assert(_G.a == "aaax")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: other generic tests", { skip: true }, function (t) {
+test.skip("[test-suite] api: other generic tests", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
testamem("string creation", function ()
local a, b = string.gsub("alo alo", "(a)", function (x) return x..'b' end)
@@ -2138,31 +1599,19 @@ test("[test-suite] api: other generic tests", { skip: true }, function (t) {
return (#table.concat(a, ",") == 20*lim + lim - 1)
end)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + memprefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing some auxlib functions", function (t) {
+test("[test-suite] api: testing some auxlib functions", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function gsub (a, b, c)
a, b = T.testC("gsub 2 3 4; gettop; return 2", a, b, c)
@@ -2175,31 +1624,19 @@ test("[test-suite] api: testing some auxlib functions", function (t) {
assert(gsub("", "alo", "//") == "")
assert(gsub("...", ".", "/.") == "/././.")
assert(gsub("...", "...", "") == "")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] api: testing luaL_newmetatable", function (t) {
+test("[test-suite] api: testing luaL_newmetatable", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local mt_xuxu, res, top = T.testC("newmetatable xuxu; gettop; return 3")
assert(type(mt_xuxu) == "table" and res and top == 3)
@@ -2247,25 +1684,10 @@ test("[test-suite] api: testing luaL_newmetatable", function (t) {
assert(r.xuxu == mt_xuxu and r.xuxu1 == d)
r.xuxu = nil; r.xuxu1 = nil
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
diff --git a/tests/test-suite/attrib.js b/test/test-suite/attrib.test.js
index 5053a31..bb07e62 100644
--- a/tests/test-suite/attrib.js
+++ b/test/test-suite/attrib.test.js
@@ -1,13 +1,14 @@
"use strict";
-const test = require('tape');
-
-const lua = require('../../src/lua.js');
+const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
-const lualib = require('../../src/lualib.js');
+const lualib = require('../../src/lualib.js');
const {to_luastring} = require("../../src/fengaricore.js");
-test("[test-suite] attrib: testing require", function (t) {
+test("[test-suite] attrib: testing require", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(require"string" == string)
assert(require"math" == math)
@@ -22,7 +23,7 @@ test("[test-suite] attrib: testing require", function (t) {
assert(type(package.preload) == "table")
assert(type(package.config) == "string")
- print("package config: "..string.gsub(package.config, "\\n", "|"))
+ -- print("package config: "..string.gsub(package.config, "\\n", "|"))
do
-- create a path with 'max' templates,
@@ -52,34 +53,25 @@ test("[test-suite] attrib: testing require", function (t) {
assert(not s and string.find(err, "package.path"))
package.path = oldpath
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
+
// TODO: when io.write etc.
-test("[test-suite] attrib: system specific tests for 'require'", { skip: true }, function (t) {
+test.skip("[test-suite] attrib: system specific tests for 'require'", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
});
-test("[test-suite] attrib: testing assignments, logical operators, and constructors", function (t) {
+test("[test-suite] attrib: testing assignments, logical operators, and constructors", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local res, res2 = 27
@@ -168,30 +160,18 @@ test("[test-suite] attrib: testing assignments, logical operators, and construct
assert(a[1]==10 and a[-3]==a.a and a[f]==print and a.x=='a' and not a.y)
a[1], f(a)[2], b, c = {['alo']=assert}, 10, a[1], a[f], 6, 10, 23, f(a), 2
a[1].alo(a[2]==10 and b==10 and c==print)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] attrib: test of large float/integer indices ", function (t) {
+test("[test-suite] attrib: test of large float/integer indices ", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
a = {}
a[true] = 20
@@ -244,30 +224,18 @@ test("[test-suite] attrib: test of large float/integer indices ", function (t) {
assert(a[maxintF] == 20 and a[maxintF - 1.0] == 11 and
a[-maxintF] == 22 and a[-maxintF + 1.0] == 13)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] attrib: test conflicts in multiple assignment", function (t) {
+test("[test-suite] attrib: test conflicts in multiple assignment", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local a,i,j,b
@@ -276,30 +244,18 @@ test("[test-suite] attrib: test conflicts in multiple assignment", function (t)
assert(i == 2 and b[1] == 1 and a == 1 and j == b and b[2] == 2 and
b[3] == 1)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] attrib: repeat test with upvalues", function (t) {
+test("[test-suite] attrib: repeat test with upvalues", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local a,i,j,b
@@ -314,30 +270,18 @@ test("[test-suite] attrib: repeat test with upvalues", function (t) {
(function (a) t[a], a = 10, 20 end)(1);
assert(t[1] == 10)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] attrib: bug in 5.2 beta", function (t) {
+test("[test-suite] attrib: bug in 5.2 beta", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function foo ()
local a
@@ -350,24 +294,9 @@ test("[test-suite] attrib: bug in 5.2 beta", function (t) {
local a, b = foo()()
assert(a == 3 and b == 14)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
diff --git a/tests/test-suite/bitwise.js b/test/test-suite/bitwise.test.js
index 17e3c84..bf8de5c 100644
--- a/tests/test-suite/bitwise.js
+++ b/test/test-suite/bitwise.test.js
@@ -1,10 +1,8 @@
"use strict";
-const test = require('tape');
-
-const lua = require('../../src/lua.js');
+const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
-const lualib = require('../../src/lualib.js');
+const lualib = require('../../src/lualib.js');
const {to_luastring} = require("../../src/fengaricore.js");
const prefix = `
@@ -116,7 +114,10 @@ const prefix = `
local bit32 = require'bit32'
`;
-test("[test-suite] bitwise: testing bitwise operations", function (t) {
+test("[test-suite] bitwise: testing bitwise operations", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local numbits = string.packsize('j') * 8
@@ -175,30 +176,18 @@ test("[test-suite] bitwise: testing bitwise operations", function (t) {
-- embedded zeros
assert(not pcall(function () return "0xffffffffffffffff\\0" | 0 end))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] bitwise: testing bitwise library", function (t) {
+test("[test-suite] bitwise: testing bitwise library", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(bit32.band() == bit32.bnot(0))
assert(bit32.btest() == true)
@@ -207,30 +196,18 @@ test("[test-suite] bitwise: testing bitwise library", function (t) {
assert(bit32.band() == bit32.band(0xffffffff))
assert(bit32.band(1,2) == 0)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] bitwise: out-of-range numbers", function (t) {
+test("[test-suite] bitwise: out-of-range numbers", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(bit32.band(-1) == 0xffffffff)
assert(bit32.band((1 << 33) - 1) == 0xffffffff)
@@ -284,30 +261,18 @@ test("[test-suite] bitwise: out-of-range numbers", function (t) {
assert(0x12345678 >> 8 == 0x00123456)
assert(0x12345678 >> 32 == 0)
assert(0x12345678 >> -32 == 0x1234567800000000)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] bitwise: some special cases", function (t) {
+test("[test-suite] bitwise: some special cases", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local c = {0, 1, 2, 3, 10, 0x80000000, 0xaaaaaaaa, 0x55555555,
0xffffffff, 0x7fffffff}
@@ -339,30 +304,18 @@ test("[test-suite] bitwise: some special cases", function (t) {
assert(bit32.lshift(bit32.lshift(b, -4), 4) == bit32.band(b, bit32.bnot(0xf)))
assert(bit32.rshift(bit32.rshift(b, 4), -4) == bit32.band(b, bit32.bnot(0xf)))
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] bitwise: for this test, use at most 24 bits (mantissa of a single float)", function (t) {
+test("[test-suite] bitwise: for this test, use at most 24 bits (mantissa of a single float)", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
c = {0, 1, 2, 3, 10, 0x800000, 0xaaaaaa, 0x555555, 0xffffff, 0x7fffff}
for _, b in pairs(c) do
@@ -378,30 +331,18 @@ test("[test-suite] bitwise: for this test, use at most 24 bits (mantissa of a si
assert(not pcall(bit32.lshift, 45))
assert(not pcall(bit32.lshift, 45, print))
assert(not pcall(bit32.rshift, 45, print))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] bitwise: testing extract/replace", function (t) {
+test("[test-suite] bitwise: testing extract/replace", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(bit32.extract(0x12345678, 0, 4) == 8)
assert(bit32.extract(0x12345678, 4, 4) == 7)
@@ -421,57 +362,33 @@ test("[test-suite] bitwise: testing extract/replace", function (t) {
assert(bit32.replace(0, -1, 4) == 2^4)
assert(bit32.replace(-1, 0, 31) == (1 << 31) - 1)
assert(bit32.replace(-1, 0, 1, 2) == (1 << 32) - 7)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] bitwise: testing conversion of floats", function (t) {
+test("[test-suite] bitwise: testing conversion of floats", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(bit32.bor(3.0) == 3)
assert(bit32.bor(-4.0) == 0xfffffffc)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] bitwise: large floats and large-enough integers?", function (t) {
+test("[test-suite] bitwise: large floats and large-enough integers?", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
if 2.0^50 < 2.0^50 + 1.0 and 2.0^50 < (-1 >> 1) then
assert(bit32.bor(2.0^32 - 5.0) == 0xfffffffb)
@@ -479,24 +396,9 @@ test("[test-suite] bitwise: large floats and large-enough integers?", function (
assert(bit32.bor(2.0^48 - 5.0) == 0xfffffffb)
assert(bit32.bor(-2.0^48 - 6.0) == 0xfffffffa)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
diff --git a/tests/test-suite/calls.js b/test/test-suite/calls.test.js
index 2044e5c..1604337 100644
--- a/tests/test-suite/calls.js
+++ b/test/test-suite/calls.test.js
@@ -1,13 +1,14 @@
"use strict";
-const test = require('tape');
-
-const lua = require('../../src/lua.js');
+const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
-const lualib = require('../../src/lualib.js');
+const lualib = require('../../src/lualib.js');
const {to_luastring} = require("../../src/fengaricore.js");
-test("[test-suite] calls: test 'type'", function (t) {
+test("[test-suite] calls: test 'type'", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(type(1<2) == 'boolean')
assert(type(true) == 'boolean' and type(false) == 'boolean')
@@ -21,30 +22,18 @@ test("[test-suite] calls: test 'type'", function (t) {
function f (x) return a:x (x) end
assert(type(f) == 'function')
assert(not pcall(type))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] calls: test error in 'print'", function (t) {
+test("[test-suite] calls: test error in 'print'", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do -- test error in 'print' too...
local tostring = _ENV.tostring
@@ -59,30 +48,18 @@ test("[test-suite] calls: test error in 'print'", function (t) {
_ENV.tostring = tostring
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] calls: testing local-function recursion", function (t) {
+test("[test-suite] calls: testing local-function recursion", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
fact = false
do
@@ -95,30 +72,18 @@ test("[test-suite] calls: testing local-function recursion", function (t) {
assert(fact(5) == 120)
end
assert(fact == false)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] calls: testing declarations", function (t) {
+test("[test-suite] calls: testing declarations", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
a = {i = 10}
self = 20
@@ -202,30 +167,18 @@ test("[test-suite] calls: testing declarations", function (t) {
a = nil
(function (x) a=x end)(23)
assert(a == 23 and (function (x) return x*2 end)(20) == 40)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] calls: testing closures", function (t) {
+test("[test-suite] calls: testing closures", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
-- fixed-point operator
Z = function (le)
@@ -260,30 +213,18 @@ test("[test-suite] calls: testing closures", function (t) {
assert(f(9, 16) == 10+11+12+13+10+9+16+10)
Z, F, f = nil
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] calls: testing multiple returns", function (t) {
+test("[test-suite] calls: testing multiple returns", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
function unlpack (t, i)
i = i or 1
@@ -318,59 +259,35 @@ test("[test-suite] calls: testing multiple returns", function (t) {
a = ret2{ unlpack{1,2,3}, unlpack{3,2,1}, unlpack{"a", "b"}}
assert(a[1] == 1 and a[2] == 3 and a[3] == "a" and a[4] == "b")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] calls: testing calls with 'incorrect' arguments", function (t) {
+test("[test-suite] calls: testing calls with 'incorrect' arguments", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
rawget({}, "x", 1)
rawset({}, "x", 1, 2)
assert(math.sin(1,2) == math.sin(1))
table.sort({10,9,8,4,19,23,0,0}, function (a,b) return a<b end, "extra arg")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] calls: test for generic load", function (t) {
+test("[test-suite] calls: test for generic load", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local x = "-- a comment\\0\\0\\0\\n x = 10 + \\n23; \\
local a = function () x = 'hi' end; \\
@@ -419,56 +336,32 @@ test("[test-suite] calls: test for generic load", function (t) {
cannotload("unexpected symbol", load(read1("*a = 123")))
cannotload("unexpected symbol", load("*a = 123"))
cannotload("hhi", load(function () error("hhi") end))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] calls: any value is valid for _ENV", function (t) {
+test("[test-suite] calls: any value is valid for _ENV", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(load("return _ENV", nil, nil, 123)() == 123)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] calls: load when _ENV is not first upvalue", function (t) {
+test("[test-suite] calls: load when _ENV is not first upvalue", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local x; XX = 123
local function h ()
@@ -482,30 +375,18 @@ test("[test-suite] calls: load when _ENV is not first upvalue", function (t) {
assert(x() == 123)
assert(assert(load("return XX + ...", nil, nil, {XX = 13}))(4) == 17)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] calls: test generic load with nested functions", function (t) {
+test("[test-suite] calls: test generic load with nested functions", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
function read1 (x)
local i = 0
@@ -527,30 +408,18 @@ test("[test-suite] calls: test generic load with nested functions", function (t)
a = assert(load(read1(x)))
assert(a()(2)(3)(10) == 15)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] calls: test for dump/undump with upvalues", function (t) {
+test("[test-suite] calls: test for dump/undump with upvalues", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a, b = 20, 30
x = load(string.dump(function (x)
@@ -567,30 +436,18 @@ test("[test-suite] calls: test for dump/undump with upvalues", function (t) {
assert(x() == 23)
x("set")
assert(x() == 24)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] calls: test for dump/undump with many upvalues", function (t) {
+test("[test-suite] calls: test for dump/undump with many upvalues", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local nup = 200 -- maximum number of local variables
@@ -614,30 +471,18 @@ test("[test-suite] calls: test for dump/undump with many upvalues", function (t)
end
assert(f() == 10 * nup)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] calls: test for long method names", function (t) {
+test("[test-suite] calls: test for long method names", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local t = {x = 1}
@@ -646,58 +491,34 @@ test("[test-suite] calls: test for long method names", function (t) {
end
assert(t:_012345678901234567890123456789012345678901234567890123456789() == 1)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] calls: test for bug in parameter adjustment", function (t) {
+test("[test-suite] calls: test for bug in parameter adjustment", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert((function () return nil end)(4) == nil)
assert((function () local a; return a end)(4) == nil)
assert((function (a) return a end)() == nil)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] calls: testing binary chunks", function (t) {
+test("[test-suite] calls: testing binary chunks", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local header = string.pack("c4BBc6BBBBBj",
@@ -733,24 +554,9 @@ test("[test-suite] calls: testing binary chunks", function (t) {
end
assert(assert(load(c))() == 10)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
diff --git a/tests/test-suite/closure.js b/test/test-suite/closure.test.js
index 79a2226..d44d908 100644
--- a/tests/test-suite/closure.js
+++ b/test/test-suite/closure.test.js
@@ -1,13 +1,14 @@
"use strict";
-const test = require('tape');
-
-const lua = require('../../src/lua.js');
+const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
-const lualib = require('../../src/lualib.js');
+const lualib = require('../../src/lualib.js');
const {to_luastring} = require("../../src/fengaricore.js");
-test("[test-suite] closure: testing equality", function (t) {
+test("[test-suite] closure: testing equality", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
a = {}
for i = 1, 5 do a[i] = function (x) return x + a + _ENV end end
@@ -20,30 +21,18 @@ test("[test-suite] closure: testing equality", function (t) {
return function (x) return math.sin(_ENV[x]) end
end
assert(f() == f())
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] closure: testing closures with 'for' control variable", function (t) {
+test("[test-suite] closure: testing closures with 'for' control variable", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
a = {}
for i=1,10 do
@@ -73,30 +62,18 @@ test("[test-suite] closure: testing closures with 'for' control variable", funct
a[2].set('a', 'b')
r,s = a[2].get()
assert(r == "a" and s == "b")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] closure: testing closures with 'for' control variable x break", function (t) {
+test("[test-suite] closure: testing closures with 'for' control variable x break", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local t = {"a", "b"}
@@ -113,30 +90,18 @@ test("[test-suite] closure: testing closures with 'for' control variable x break
end
assert(({f()})[1] == 1)
assert(({f()})[2] == "a")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] closure: testing closure x break x return x errors", function (t) {
+test("[test-suite] closure: testing closure x break x return x errors", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local b
function f(x)
@@ -169,30 +134,18 @@ test("[test-suite] closure: testing closure x break x return x errors", function
pcall(f, 4);
assert(b('get') == 'xuxu')
b('set', 10); assert(b('get') == 14)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] closure: testing multi-level closure", function (t) {
+test("[test-suite] closure: testing multi-level closure", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local w
function f(x)
@@ -204,30 +157,18 @@ test("[test-suite] closure: testing multi-level closure", function (t) {
y = f(10)
w = 1.345
assert(y(20)(30) == 60+w)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] closure: testing closures x repeat-until", function (t) {
+test("[test-suite] closure: testing closures x repeat-until", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = {}
local i = 1
@@ -236,30 +177,18 @@ test("[test-suite] closure: testing closures x repeat-until", function (t) {
a[i] = function () i = x+1; return x end
until i > 10 or a[i]() ~= x
assert(i == 11 and a[1]() == 1 and a[3]() == 3 and i == 4)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] closure: testing closures created in 'then' and 'else' parts of 'if's", function (t) {
+test("[test-suite] closure: testing closures created in 'then' and 'else' parts of 'if's", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
a = {}
for i = 1, 10 do
@@ -289,30 +218,18 @@ test("[test-suite] closure: testing closures created in 'then' and 'else' parts
for i = 1, 10 do
assert(a[i](i * 10) == i % 3 and a[i]() == i * 10)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] closure: test for correctly closing upvalues in tail calls of vararg functions", function (t) {
+test("[test-suite] closure: test for correctly closing upvalues in tail calls of vararg functions", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function t ()
local function c(a,b) assert(a=="test" and b=="OK") end
@@ -321,24 +238,9 @@ test("[test-suite] closure: test for correctly closing upvalues in tail calls of
return v(function() return x end)
end
t()
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
diff --git a/tests/test-suite/code.js b/test/test-suite/code.test.js
index 57c97cb..377dd63 100644
--- a/tests/test-suite/code.js
+++ b/test/test-suite/code.test.js
@@ -1,15 +1,16 @@
"use strict";
-const test = require('tape');
-
-const lua = require('../../src/lua.js');
+const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
-const lualib = require('../../src/lualib.js');
+const lualib = require('../../src/lualib.js');
const {to_luastring} = require("../../src/fengaricore.js");
-const ltests = require('./ltests.js');
+const ltests = require('./ltests.js');
+
+test("[test-suite] code: testing reuse in constant table", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
-test("[test-suite] code: testing reuse in constant table", function (t) {
let luaCode = `
local function checkKlist (func, list)
local k = T.listk(func)
@@ -30,27 +31,12 @@ test("[test-suite] code: testing reuse in constant table", function (t) {
end
checkKlist(foo, {3, 0, 0.0, 3.78/4, -3.78/4, -3.79/4, 3.0})
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
@@ -59,7 +45,7 @@ const prefix = `
local arg = {...}
local c = T.listcode(f)
for i=1, #arg do
- print(arg[i], c[i])
+ -- print(arg[i], c[i])
assert(string.find(c[i], '- '..arg[i]..' *%d'))
end
assert(c[#arg+2] == nil)
@@ -77,36 +63,28 @@ const prefix = `
end
`;
-test("[test-suite] code: some basic instructions", function (t) {
+
+test("[test-suite] code: some basic instructions", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
check(function ()
(function () end){f()}
end, 'CLOSURE', 'NEWTABLE', 'GETTABUP', 'CALL', 'SETLIST', 'CALL', 'RETURN')
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] code: sequence of LOADNILs", function (t) {
+test("[test-suite] code: sequence of LOADNILs", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
check(function ()
local a,b,c
@@ -125,58 +103,34 @@ test("[test-suite] code: sequence of LOADNILs", function (t) {
d=nil;c=nil;b=nil;a=nil
assert(a == nil and b == nil and c == nil and d == nil)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] code: single return", function (t) {
+test("[test-suite] code: single return", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
check (function (a,b,c) return a end, 'RETURN')
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] code: infinite loops", function (t) {
+test("[test-suite] code: infinite loops", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
check(function () while true do local a = -1 end end,
'LOADK', 'JMP', 'RETURN')
@@ -186,89 +140,53 @@ test("[test-suite] code: infinite loops", function (t) {
check(function () repeat local x = 1 until true end,
'LOADK', 'RETURN')
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] code: concat optimization", function (t) {
+test("[test-suite] code: concat optimization", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
check(function (a,b,c,d) return a..b..c..d end,
'MOVE', 'MOVE', 'MOVE', 'MOVE', 'CONCAT', 'RETURN')
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] code: not", function (t) {
+test("[test-suite] code: not", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
check(function () return not not nil end, 'LOADBOOL', 'RETURN')
check(function () return not not false end, 'LOADBOOL', 'RETURN')
check(function () return not not true end, 'LOADBOOL', 'RETURN')
check(function () return not not 1 end, 'LOADBOOL', 'RETURN')
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] code: direct access to locals", function (t) {
+test("[test-suite] code: direct access to locals", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
check(function ()
local a,b,c,d
@@ -279,31 +197,19 @@ test("[test-suite] code: direct access to locals", function (t) {
'MUL',
'DIV', 'ADD', 'GETTABLE', 'SUB', 'GETTABLE', 'POW',
'UNM', 'SETTABLE', 'SETTABLE', 'RETURN')
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] code: direct access to constants", function (t) {
+test("[test-suite] code: direct access to constants", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
check(function ()
local a,b
@@ -326,31 +232,19 @@ test("[test-suite] code: direct access to constants", function (t) {
a[true] = false
end,
'LOADNIL', 'SETTABLE', 'RETURN')
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] code: constant folding", function (t) {
+test("[test-suite] code: constant folding", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function checkK (func, val)
check(func, 'LOADK', 'RETURN')
@@ -372,61 +266,37 @@ test("[test-suite] code: constant folding", function (t) {
checkK(function () return ~(~0xFF0 | 0xFF0) end, 0)
checkK(function () return ~~-100024.0 end, -100024)
checkK(function () return ((100 << 6) << -4) >> 2 end, 100)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] code: no folding", function (t) {
+test("[test-suite] code: no folding", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
check(function () return -0.0 end, 'LOADK', 'UNM', 'RETURN')
check(function () return 3/0 end, 'DIV', 'RETURN')
check(function () return 0%0 end, 'MOD', 'RETURN')
check(function () return -4//0 end, 'IDIV', 'RETURN')
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] code: bug in constant folding for 5.1", function (t) {
+test("[test-suite] code: bug in constant folding for 5.1", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
check(function () return -nil end, 'LOADNIL', 'UNM', 'RETURN')
@@ -444,31 +314,19 @@ test("[test-suite] code: bug in constant folding for 5.1", function (t) {
'MOVE', 'MOVE', 'MOVE',
-- no code for a = a
'RETURN')
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] code: x == nil , x ~= nil", function (t) {
+test("[test-suite] code: x == nil , x ~= nil", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
checkequal(function () if (a==nil) then a=1 end; if a~=nil then a=1 end end,
function () if (a==9) then a=1 end; if a~=9 then a=1 end end)
@@ -481,31 +339,19 @@ test("[test-suite] code: x == nil , x ~= nil", function (t) {
checkequal(function (l) local a; return 0 <= a and a <= l end,
function (l) local a; return not (not(a >= 0) or not(a <= l)) end)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] code: if-goto optimizations", function (t) {
+test("[test-suite] code: if-goto optimizations", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
check(function (a, b, c, d, e)
if a == b then goto l1
@@ -528,25 +374,10 @@ test("[test-suite] code: if-goto optimizations", function (t) {
function (a) while a < 10 do a = a + 1 end end,
function (a) while true do if not(a < 10) then break end; a = a + 1; end end
)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
diff --git a/tests/test-suite/constructs.js b/test/test-suite/constructs.test.js
index 93bbf1a..e79778a 100644
--- a/tests/test-suite/constructs.js
+++ b/test/test-suite/constructs.test.js
@@ -1,10 +1,8 @@
"use strict";
-const test = require('tape');
-
-const lua = require('../../src/lua.js');
+const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
-const lualib = require('../../src/lualib.js');
+const lualib = require('../../src/lualib.js');
const {to_luastring} = require("../../src/fengaricore.js");
const checkload = `
@@ -13,61 +11,40 @@ const checkload = `
end
`;
-test('[test-suite] constructs: testing semicolons', function (t) {
+test('[test-suite] constructs: testing semicolons', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do ;;; end
; do ; a = 3; assert(a == 3) end;
;
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(checkload + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(checkload + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test('[test-suite] constructs: invalid operations should not raise errors when not executed', function (t) {
+test('[test-suite] constructs: invalid operations should not raise errors when not executed', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
if false then a = 3 // 0; a = 0 % 0 end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(checkload + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(checkload + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test('[test-suite] constructs: testing priorities', function (t) {
+test('[test-suite] constructs: testing priorities', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(2^3^2 == 2^(3^2));
assert(2^3*4 == (2^3)*4);
@@ -109,30 +86,18 @@ test('[test-suite] constructs: testing priorities', function (t) {
assert((x>y) and x or y == 2);
assert(1234567890 == tonumber('1234567890') and 1234567890+1 == 1234567891)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(checkload + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(checkload + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test('[test-suite] constructs: silly loops', function (t) {
+test('[test-suite] constructs: silly loops', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
repeat until 1; repeat until true;
while false do end; while nil do end;
@@ -295,29 +260,17 @@ 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 () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(checkload + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(checkload + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test.skip('[test-suite] constructs: huge loops, upvalue', function (t) {
+test.skip('[test-suite] constructs: huge loops, upvalue', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
-- sometimes will be 0, sometimes will not...
_ENV.GLOB1 = math.floor(os.time()) % 2
@@ -379,33 +332,21 @@ test.skip('[test-suite] constructs: huge loops, upvalue', function (t) {
IX = false
assert(p() == v[2] and IX == not not v[2])
i = i + 1
- if i % 60000 == 0 then print('+') end
+ -- if i % 60000 == 0 then print('+') end
end
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(checkload + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(checkload + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] constructs: testing some syntax errors (chosen through 'gcov')", function (t) {
+test("[test-suite] constructs: testing some syntax errors (chosen through 'gcov')", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
_soft = true
@@ -418,24 +359,9 @@ test("[test-suite] constructs: testing some syntax errors (chosen through 'gcov'
s = "while true do " .. s .. "end"
checkload(s, "too long")
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(checkload + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(checkload + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
diff --git a/tests/test-suite/coroutine.js b/test/test-suite/coroutine.test.js
index 969c65e..de92317 100644
--- a/tests/test-suite/coroutine.js
+++ b/test/test-suite/coroutine.test.js
@@ -1,13 +1,11 @@
"use strict";
-const test = require('tape');
-
-const lua = require('../../src/lua.js');
+const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
-const lualib = require('../../src/lualib.js');
+const lualib = require('../../src/lualib.js');
const {to_luastring} = require("../../src/fengaricore.js");
-const ltests = require('./ltests.js');
+const ltests = require('./ltests.js');
const prefix = `
mt = {
@@ -57,64 +55,43 @@ const prefix = `
end
`;
-test("[test-suite] coroutine: is main thread", function (t) {
+test("[test-suite] coroutine: is main thread", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local main, ismain = coroutine.running()
assert(type(main) == "thread" and ismain)
assert(not coroutine.resume(main))
assert(not coroutine.isyieldable())
assert(not pcall(coroutine.yield))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: trivial errors", function (t) {
+test("[test-suite] coroutine: trivial errors", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(not pcall(coroutine.resume, 0))
assert(not pcall(coroutine.status, 0))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: tests for multiple yield/resume arguments", function (t) {
+test("[test-suite] coroutine: tests for multiple yield/resume arguments", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function eqtab (t1, t2)
assert(#t1 == #t2)
@@ -158,30 +135,18 @@ test("[test-suite] coroutine: tests for multiple yield/resume arguments", functi
assert(coroutine.status(f) == "dead")
s, a = coroutine.resume(f, "xuxu")
assert(not s and string.find(a, "dead") and coroutine.status(f) == "dead")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: yields in tail calls", function (t) {
+test("[test-suite] coroutine: yields in tail calls", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function foo (i) return coroutine.yield(i) end
f = coroutine.wrap(function ()
@@ -192,30 +157,18 @@ test("[test-suite] coroutine: yields in tail calls", function (t) {
end)
for i=1,10 do _G.x = i; assert(f(i) == i) end
_G.x = 'xuxu'; assert(f('xuxu') == 'a')
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: recursive", function (t) {
+test("[test-suite] coroutine: recursive", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
function pf (n, i)
coroutine.yield(n)
@@ -228,30 +181,18 @@ test("[test-suite] coroutine: recursive", function (t) {
assert(f(1, 1) == s)
s = s*i
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: sieve", function (t) {
+test("[test-suite] coroutine: sieve", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
function gen (n)
return coroutine.wrap(function ()
@@ -281,30 +222,18 @@ test("[test-suite] coroutine: sieve", function (t) {
assert(#a == 25 and a[#a] == 97)
x, a = nil
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: yielding across JS boundaries", function (t) {
+test("[test-suite] coroutine: yielding across JS boundaries", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local f = function (s, i) return coroutine.yield(i) end
@@ -333,30 +262,18 @@ test("[test-suite] coroutine: yielding across JS boundaries", function (t) {
assert(co() == 10)
r, msg = co(100)
assert(not r and msg == 240)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: unyieldable JS call", function (t) {
+test("[test-suite] coroutine: unyieldable JS call", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local function f (c)
@@ -371,30 +288,18 @@ test("[test-suite] coroutine: unyieldable JS call", function (t) {
end)
assert(co() == "aa")
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: errors in coroutines", function (t) {
+test("[test-suite] coroutine: errors in coroutines", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
function foo ()
assert(debug.getinfo(1).currentline == debug.getinfo(foo).linedefined + 1)
@@ -416,30 +321,18 @@ test("[test-suite] coroutine: errors in coroutines", function (t) {
assert(not a and b == foo and coroutine.status(x) == "dead")
a,b = coroutine.resume(x)
assert(not a and string.find(b, "dead") and coroutine.status(x) == "dead")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: co-routines x for loop", function (t) {
+test("[test-suite] coroutine: co-routines x for loop", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
function all (a, n, k)
if k == 0 then coroutine.yield(a)
@@ -456,30 +349,18 @@ test("[test-suite] coroutine: co-routines x for loop", function (t) {
a = a+1
end
assert(a == 5^4)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: old bug: attempt to resume itself", function (t) {
+test("[test-suite] coroutine: old bug: attempt to resume itself", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
function co_func (current_co)
assert(coroutine.running() == current_co)
@@ -499,30 +380,18 @@ test("[test-suite] coroutine: old bug: attempt to resume itself", function (t) {
assert(a == true and b == 10)
assert(coroutine.resume(co, co) == false)
assert(coroutine.resume(co, co) == false)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: old bug: other old bug when attempting to resume itself", function (t) {
+test("[test-suite] coroutine: old bug: other old bug when attempting to resume itself", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local A = coroutine.running()
@@ -534,30 +403,18 @@ test("[test-suite] coroutine: old bug: other old bug when attempting to resume i
st, res = A()
assert(not st and string.find(res, "non%-suspended"))
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: attempt to resume 'normal' coroutine", function (t) {
+test("[test-suite] coroutine: attempt to resume 'normal' coroutine", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local co1, co2
co1 = coroutine.create(function () return co2() end)
@@ -570,58 +427,34 @@ test("[test-suite] coroutine: attempt to resume 'normal' coroutine", function (t
a,b = coroutine.resume(co1)
assert(a and b == 3)
assert(coroutine.status(co1) == 'dead')
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: infinite recursion of coroutines", function (t) {
+test("[test-suite] coroutine: infinite recursion of coroutines", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
a = function(a) coroutine.wrap(a)(a) end
assert(not pcall(a, a))
a = nil
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: access to locals of erroneous coroutines", function (t) {
+test("[test-suite] coroutine: access to locals of erroneous coroutines", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local x = coroutine.create (function ()
local a = 10
@@ -634,29 +467,17 @@ test("[test-suite] coroutine: access to locals of erroneous coroutines", functio
assert(not coroutine.resume(x, 1, 1, 1, 1, 1, 1, 1))
assert(_G.f() == 11)
assert(_G.f() == 12)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: leaving a pending coroutine open", function (t) {
+test("[test-suite] coroutine: leaving a pending coroutine open", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
_X = coroutine.wrap(function ()
local a = 10
@@ -665,30 +486,18 @@ test("[test-suite] coroutine: leaving a pending coroutine open", function (t) {
end)
_X()
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: stack overflow", function (t) {
+test("[test-suite] coroutine: stack overflow", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
-- bug (stack overflow)
local j = 2^9
@@ -705,30 +514,18 @@ test("[test-suite] coroutine: stack overflow", function (t) {
assert(not r)
end
co = nil
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: testing yields inside metamethods", function (t) {
+test("[test-suite] coroutine: testing yields inside metamethods", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = new(10)
local b = new(12)
@@ -765,30 +562,18 @@ test("[test-suite] coroutine: testing yields inside metamethods", function (t) {
a.BB = print
return a.BB
end, {"nidx", "idx"}) == print)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: tests for comparsion operators", function (t) {
+test("[test-suite] coroutine: tests for comparsion operators", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local mt1 = {
@@ -829,30 +614,18 @@ test("[test-suite] coroutine: tests for comparsion operators", function (t) {
run(test)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: getuptable & setuptable", function (t) {
+test("[test-suite] coroutine: getuptable & setuptable", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do local _ENV = _ENV
f = function () AAA = BBB + 1; return AAA end
@@ -861,30 +634,18 @@ test("[test-suite] coroutine: getuptable & setuptable", function (t) {
debug.setupvalue(f, 1, g)
assert(run(f, {"idx", "nidx", "idx"}) == 11)
assert(g.k.AAA == 11)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: testing yields inside 'for' iterators", function (t) {
+test("[test-suite] coroutine: testing yields inside 'for' iterators", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local f = function (s, i)
if i%2 == 0 then coroutine.yield(nil, "for") end
@@ -896,26 +657,11 @@ test("[test-suite] coroutine: testing yields inside 'for' iterators", function (
for i in f, 4, 0 do s = s + i end
return s
end, {"for", "for", "for"}) == 10)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
@@ -930,7 +676,10 @@ const jsprefix = `
end
`;
-test("[test-suite] coroutine: testing yields inside hooks", function (t) {
+test("[test-suite] coroutine: testing yields inside hooks", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local A, B = 0, 0
@@ -950,31 +699,19 @@ test("[test-suite] coroutine: testing yields inside hooks", function (t) {
end
assert(B // A == 7) -- fact(7) // fact(6)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(jsprefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(jsprefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: testing yields inside line hook", function (t) {
+test("[test-suite] coroutine: testing yields inside line hook", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local line = debug.getinfo(1, "l").currentline + 2 -- get line number
local function foo ()
@@ -993,31 +730,19 @@ test("[test-suite] coroutine: testing yields inside line hook", function (t) {
_G.X = nil; co(); assert(_G.X == line + 2 and _G.XX == nil)
_G.X = nil; co(); assert(_G.X == line + 3 and _G.XX == 20)
assert(co() == 10)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(jsprefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(jsprefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: testing yields in count hook", function (t) {
+test("[test-suite] coroutine: testing yields in count hook", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local line = debug.getinfo(1, "l").currentline + 2 -- get line number
local function foo ()
@@ -1034,31 +759,19 @@ test("[test-suite] coroutine: testing yields in count hook", function (t) {
local c = 0
repeat c = c + 1; local a = co() until a == 10
assert(_G.XX == 20 and c >= 5)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(jsprefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(jsprefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: testing yields inside line hook", function (t) {
+test("[test-suite] coroutine: testing yields inside line hook", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local line = debug.getinfo(1, "l").currentline + 2 -- get line number
local function foo ()
@@ -1084,31 +797,19 @@ test("[test-suite] coroutine: testing yields inside line hook", function (t) {
repeat c = c + 1; local a = co() until a == 10
assert(_G.XX == 20 and c >= 5)
_G.X = nil; _G.XX = nil
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(jsprefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(jsprefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: testing debug library on a coroutine suspended inside a hook", function (t) {
+test("[test-suite] coroutine: testing debug library on a coroutine suspended inside a hook", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
-- testing debug library on a coroutine suspended inside a hook
@@ -1136,31 +837,19 @@ test("[test-suite] coroutine: testing debug library on a coroutine suspended ins
assert(v[1] == true and v[2] == 2 and v[3] == 20 and v[4] == nil)
assert(not coroutine.resume(c))
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: testing debug library on last function in a suspended coroutine", function (t) {
+test("[test-suite] coroutine: testing debug library on last function in a suspended coroutine", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
-- testing debug library on last function in a suspended coroutine
@@ -1172,31 +861,19 @@ test("[test-suite] coroutine: testing debug library on last function in a suspen
a, b = debug.getlocal(c, 0, 2)
assert(b == 10)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: reusing a thread", function (t) {
+test("[test-suite] coroutine: reusing a thread", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(T.testC([[
newthread # create thread
@@ -1218,31 +895,19 @@ test("[test-suite] coroutine: reusing a thread", function (t) {
]], function (...) return ... end) == 'b b b')
assert(X == 'a a a' and Y == 'OK')
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: resuming running coroutine", function (t) {
+test("[test-suite] coroutine: resuming running coroutine", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
C = coroutine.create(function ()
return T.testC([[
@@ -1267,30 +932,18 @@ test("[test-suite] coroutine: resuming running coroutine", function (t) {
return 4]])
assert(a == coroutine.running() and string.find(b, "non%-suspended") and
c == "ERRRUN" and d == 4)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: using a main thread as a coroutine", function (t) {
+test("[test-suite] coroutine: using a main thread as a coroutine", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local state = T.newstate()
T.loadlib(state)
@@ -1322,31 +975,19 @@ test("[test-suite] coroutine: using a main thread as a coroutine", function (t)
assert(T.doremote(state, "return B") == 'BB')
T.closestate(state)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: tests for coroutine API", function (t) {
+test("[test-suite] coroutine: tests for coroutine API", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function apico (...)
local x = {...}
@@ -1386,31 +1027,19 @@ test("[test-suite] coroutine: tests for coroutine API", function (t) {
a[7] == "YIELD" and a[8] == 3 and
a[9] == "YIELD" and a[10] == 4)
assert(not pcall(co)) -- coroutine is dead now
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: tests for coroutine API", function (t) {
+test("[test-suite] coroutine: tests for coroutine API", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
f = T.makeCfunc("pushnum 3; pushnum 5; yield 1;")
co = coroutine.wrap(function ()
@@ -1419,31 +1048,19 @@ test("[test-suite] coroutine: tests for coroutine API", function (t) {
assert(co(23,16) == 5)
assert(co(23,16) == 5)
assert(co(23,16) == 10)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: testing coroutines with C bodies", function (t) {
+test("[test-suite] coroutine: testing coroutines with C bodies", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function eqtab (t1, t2)
assert(#t1 == #t2)
@@ -1476,31 +1093,19 @@ test("[test-suite] coroutine: testing coroutines with C bodies", function (t) {
return 4; ]], f)
assert(a == 'YIELD' and b == 'a' and c == 102 and d == 'OK')
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: testing chain of suspendable C calls", function (t) {
+test("[test-suite] coroutine: testing chain of suspendable C calls", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local count = 3 -- number of levels
@@ -1531,31 +1136,19 @@ test("[test-suite] coroutine: testing chain of suspendable C calls", function (t
a = {co()}
-- three '34's (one from each pending C call)
assert(#a == 3 and a[1] == a[2] and a[2] == a[3] and a[3] == 34)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: testing yields with continuations", function (t) {
+test("[test-suite] coroutine: testing yields with continuations", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
co = coroutine.wrap(function (...) return
T.testC([[ # initial function
@@ -1608,31 +1201,19 @@ test("[test-suite] coroutine: testing yields with continuations", function (t) {
assert(x == "YIELD" and y == 4)
assert(not pcall(co)) -- coroutine should be dead
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] coroutine: bug in nCcalls", function (t) {
+test("[test-suite] coroutine: bug in nCcalls", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local co = coroutine.wrap(function ()
local a = {pcall(pcall,pcall,pcall,pcall,pcall,pcall,pcall,error,"hi")}
@@ -1641,25 +1222,10 @@ test("[test-suite] coroutine: bug in nCcalls", function (t) {
local a = {co()}
assert(a[10] == "hi")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
diff --git a/tests/test-suite/db.js b/test/test-suite/db.test.js
index 9209ab9..89ec66d 100644
--- a/tests/test-suite/db.js
+++ b/test/test-suite/db.test.js
@@ -1,10 +1,8 @@
"use strict";
-const test = require('tape');
-
-const lua = require('../../src/lua.js');
+const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
-const lualib = require('../../src/lualib.js');
+const lualib = require('../../src/lualib.js');
const {to_luastring} = require("../../src/fengaricore.js");
const prefix = `
@@ -24,7 +22,10 @@ const prefix = `
end
`;
-test("[test-suite] db: getinfo, ...line...", function (t) {
+test("[test-suite] db: getinfo, ...line...", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(not pcall(debug.getinfo, print, "X")) -- invalid option
assert(not debug.getinfo(1000)) -- out of range level
@@ -41,30 +42,18 @@ test("[test-suite] db: getinfo, ...line...", function (t) {
b.activelines[b.lastlinedefined])
assert(not b.activelines[b.linedefined] and
not b.activelines[b.lastlinedefined + 1])
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: test file and string names truncation", function (t) {
+test("[test-suite] db: test file and string names truncation", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
a = "function f () end"
local function dostring (s, x) return load(s, x)() end
@@ -89,29 +78,17 @@ test("[test-suite] db: test file and string names truncation", function (t) {
dostring(a, "=")
assert(debug.getinfo(f).short_src == "")
a = nil; f = nil;
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: local", function (t) {
+test("[test-suite] db: local", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
repeat
local g = {x = function ()
@@ -148,30 +125,18 @@ test("[test-suite] db: local", function (t) {
function g(x) if not x then return 3 end return (x('a', 'x')) end
assert(g(f) == 'a')
until 1
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: line hook", function (t) {
+test("[test-suite] db: line hook", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
test([[if
math.sin(1)
@@ -226,57 +191,33 @@ test("[test-suite] db: line hook", function (t) {
]], {1,2,1,2,1,3})
test([[for i=1,4 do a=1 end]], {1,1,1,1,1})
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: invalid levels in [gs]etlocal", function (t) {
+test("[test-suite] db: invalid levels in [gs]etlocal", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(not pcall(debug.getlocal, 20, 1))
assert(not pcall(debug.setlocal, -1, 1, 10))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: parameter names", function (t) {
+test("[test-suite] db: parameter names", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function foo (a,b,...) local d, e end
local co = coroutine.create(foo)
@@ -289,30 +230,18 @@ test("[test-suite] db: parameter names", function (t) {
assert(not debug.getlocal(co, foo, 3))
assert(not debug.getlocal(print, 1))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: vararg", function (t) {
+test("[test-suite] db: vararg", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function foo (a, ...)
local t = table.pack(...)
@@ -338,57 +267,33 @@ test("[test-suite] db: vararg", function (t) {
for i = 1, (_soft and 100 or 1000) do a[i] = i end
foo(table.unpack(a))
a = nil
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: access to vararg in non-vararg function", function (t) {
+test("[test-suite] db: access to vararg in non-vararg function", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function foo () return debug.getlocal(1, -1) end
assert(not foo(10))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: test hook presence in debug info", function (t) {
+test("[test-suite] db: test hook presence in debug info", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do -- test hook presence in debug info
assert(not debug.gethook())
@@ -473,30 +378,18 @@ test("[test-suite] db: test hook presence in debug info", function (t) {
g()
assert(a[f] and a[g] and a[assert] and a[debug.getlocal] and not a[print])
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: tests for manipulating non-registered locals (C and Lua temporaries)", function (t) {
+test("[test-suite] db: tests for manipulating non-registered locals (C and Lua temporaries)", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local n, v = debug.getlocal(0, 1)
assert(v == 0 and n == "(*temporary)")
@@ -519,30 +412,18 @@ test("[test-suite] db: tests for manipulating non-registered locals (C and Lua t
debug.sethook(nil);
assert(debug.gethook() == nil)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: testing access to function arguments", function (t) {
+test("[test-suite] db: testing access to function arguments", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function collectlocals (level)
local tab = {}
@@ -580,30 +461,18 @@ test("[test-suite] db: testing access to function arguments", function (t) {
assert(X.self == a and X.a == 1 and X.b == 2 and X.c == nil)
assert(XX == 12)
assert(debug.gethook() == nil)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: testing access to local variables in return hook (bug in 5.2)", function (t) {
+test("[test-suite] db: testing access to local variables in return hook (bug in 5.2)", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function collectlocals (level)
local tab = {}
@@ -639,30 +508,18 @@ test("[test-suite] db: testing access to local variables in return hook (bug in
debug.sethook(aux, "r"); foo(100, 200); debug.sethook()
assert(foo == nil)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: testing upvalue access", function (t) {
+test("[test-suite] db: testing upvalue access", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function getupvalues (f)
local t = {}
@@ -691,30 +548,18 @@ test("[test-suite] db: testing upvalue access", function (t) {
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) == "")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: testing count hooks", function (t) {
+test("[test-suite] db: testing count hooks", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a=0
debug.sethook(function (e) a=a+1 end, "", 1)
@@ -733,30 +578,18 @@ test("[test-suite] db: testing count hooks", function (t) {
end
debug.sethook()
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: tests for tail calls", function (t) {
+test("[test-suite] db: tests for tail calls", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function f (x)
if x then
@@ -765,8 +598,7 @@ test("[test-suite] db: tests for tail calls", function (t) {
local tail = debug.getinfo(2)
assert(tail.func == g1 and tail.istailcall == true)
assert(debug.getinfo(3, "S").what == "main")
- print"+"
- end
+ end
end
function g(x) return f(x) end
@@ -812,30 +644,18 @@ test("[test-suite] db: tests for tail calls", function (t) {
end
foo(lim)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: testing local function information", function (t) {
+test("[test-suite] db: testing local function information", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
co = load[[
local A = function ()
@@ -854,30 +674,18 @@ test("[test-suite] db: testing local function information", function (t) {
co() -- run local function definition
debug.sethook() -- turn off hook
assert(a == 2) -- ensure all two lines where hooked
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: testing traceback", function (t) {
+test("[test-suite] db: testing traceback", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(debug.traceback(print) == print)
assert(debug.traceback(print, 4) == print)
@@ -891,30 +699,18 @@ test("[test-suite] db: testing traceback", function (t) {
local st, msg = (function () return pcall end)()(debug.traceback)
assert(st == true and string.find(msg, "pcall"))
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: testing nparams, nups e isvararg", function (t) {
+test("[test-suite] db: testing nparams, nups e isvararg", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local t = debug.getinfo(print, "u")
assert(t.isvararg == true and t.nparams == 0 and t.nups == 0)
@@ -928,30 +724,18 @@ test("[test-suite] db: testing nparams, nups e isvararg", function (t) {
t = debug.getinfo(1) -- main
assert(t.isvararg == true and t.nparams == 0 and t.nups == 1 and
debug.getupvalue(t.func, 1) == "_ENV")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: testing debugging of coroutines", function (t) {
+test("[test-suite] db: testing debugging of coroutines", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function checktraceback (co, p, level)
local tb = debug.traceback(co, nil, level)
@@ -1018,32 +802,19 @@ test("[test-suite] db: testing debugging of coroutines", function (t) {
assert(debug.gethook(co) == foo)
assert(not debug.gethook())
checktraceback(co, {})
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- let b = to_luastring(luaCode);
- if (lauxlib.luaL_loadbuffer(L, b, b.length, to_luastring("@db.lua")) !== lua.LUA_OK)
- throw Error(lua.lua_tojsstring(L, -1));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ let b = to_luastring(luaCode);
+ if (lauxlib.luaL_loadbuffer(L, b, b.length, to_luastring("@db.lua")) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: check get/setlocal in coroutines", function (t) {
+test("[test-suite] db: check get/setlocal in coroutines", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
co = coroutine.create(function (x)
local a, b = coroutine.yield(x)
@@ -1059,30 +830,18 @@ test("[test-suite] db: check get/setlocal in coroutines", function (t) {
assert(not debug.setlocal(co, 1, 5, 40))
a, b = coroutine.resume(co, 100)
assert(a and b == 30)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: check traceback of suspended (or dead with error) coroutines", function (t) {
+test("[test-suite] db: check traceback of suspended (or dead with error) coroutines", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function checktraceback (co, p, level)
local tb = debug.traceback(co, nil, level)
@@ -1106,30 +865,18 @@ test("[test-suite] db: check traceback of suspended (or dead with error) corouti
end
t[1] = "'error'"
checktraceback(co, t)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: check test acessing line numbers of a coroutine from a resume inside a C function", function (t) {
+test("[test-suite] db: check test acessing line numbers of a coroutine from a resume inside a C function", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function g(x)
coroutine.yield(x)
@@ -1149,30 +896,18 @@ test("[test-suite] db: check test acessing line numbers of a coroutine from a re
assert(type(debug.getregistry()) == "table")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: test tagmethod information", function (t) {
+test("[test-suite] db: test tagmethod information", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = {}
local function f (t)
@@ -1201,30 +936,18 @@ test("[test-suite] db: test tagmethod information", function (t) {
assert (a>=b and a.op == "__le")
assert (a>b and a.op == "__lt")
assert(~a == "__bnot")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: testing for-iterator name", function (t) {
+test("[test-suite] db: testing for-iterator name", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local function f()
@@ -1233,30 +956,18 @@ test("[test-suite] db: testing for-iterator name", function (t) {
for i in f do end
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: testing traceback sizes", function (t) {
+test("[test-suite] db: testing traceback sizes", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function countlines (s)
return select(2, string.gsub(s, "\\n", ""))
@@ -1292,32 +1003,19 @@ test("[test-suite] db: testing traceback sizes", function (t) {
coroutine.wrap(checkdeep)(d, l)
end
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- let b = to_luastring(luaCode);
- if (lauxlib.luaL_loadbuffer(L, b, b.length, to_luastring("@db.lua")) !== lua.LUA_OK)
- throw Error(lua.lua_tojsstring(L, -1));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ let b = to_luastring(luaCode);
+ if (lauxlib.luaL_loadbuffer(L, b, b.length, to_luastring("@db.lua")) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: testing debug functions on chunk without debug info", function (t) {
+test("[test-suite] db: testing debug functions on chunk without debug info", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
prog = [[-- program to be loaded without debug information
local debug = require'debug'
@@ -1361,30 +1059,18 @@ test("[test-suite] db: testing debug functions on chunk without debug info", fun
local f = assert(load(string.dump(load(prog), true)))
assert(f() == 13)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] db: tests for 'source' in binary dumps", function (t) {
+test("[test-suite] db: tests for 'source' in binary dumps", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local prog = [[
@@ -1417,24 +1103,9 @@ test("[test-suite] db: tests for 'source' in binary dumps", function (t) {
debug.getinfo(g).source == '=?' and
debug.getinfo(h).source == '=?')
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
diff --git a/tests/test-suite/errors.js b/test/test-suite/errors.test.js
index 0b05e9d..83c7a90 100644
--- a/tests/test-suite/errors.js
+++ b/test/test-suite/errors.test.js
@@ -1,10 +1,8 @@
"use strict";
-const test = require('tape');
-
-const lua = require('../../src/lua.js');
+const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
-const lualib = require('../../src/lualib.js');
+const lualib = require('../../src/lualib.js');
const {to_luastring} = require("../../src/fengaricore.js");
const prefix = `
@@ -44,59 +42,38 @@ const prefix = `
end
`;
-test("[test-suite] errors: test error message with no extra info", function (t) {
+test("[test-suite] errors: test error message with no extra info", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(doit("error('hi', 0)") == 'hi')
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: test error message with no info", function (t) {
+test("[test-suite] errors: test error message with no info", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(doit("error()") == nil)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: test common errors/errors that crashed in the past", function (t) {
+test("[test-suite] errors: test common errors/errors that crashed in the past", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(doit("table.unpack({}, 1, n=2^30)"))
assert(doit("a=math.sin()"))
@@ -114,30 +91,18 @@ test("[test-suite] errors: test common errors/errors that crashed in the past",
local a = {4
]], "'}' expected (to close '{' at line 1)", "<eof>", 3)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: tests for better error messages", function (t) {
+test("[test-suite] errors: tests for better error messages", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
checkmessage("a = {} + 1", "arithmetic")
checkmessage("a = {} | 1", "bitwise operation")
@@ -160,30 +125,18 @@ test("[test-suite] errors: tests for better error messages", function (t) {
checkmessage("local aaa={bbb={}}; aaa.bbb:ddd(9)", "method 'ddd'")
checkmessage("local a,b,c; (function () a = b+1 end)()", "upvalue 'b'")
assert(not doit"local aaa={bbb={ddd=next}}; aaa.bbb:ddd(nil)")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: upvalues being indexed do not go to the stack", function (t) {
+test("[test-suite] errors: upvalues being indexed do not go to the stack", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
checkmessage("local a,b,cc; (function () a = cc[1] end)()", "upvalue 'cc'")
checkmessage("local a,b,cc; (function () a.x = 1 end)()", "upvalue 'a'")
@@ -194,30 +147,18 @@ test("[test-suite] errors: upvalues being indexed do not go to the stack", funct
checkmessage("aaa={}; x=3/aaa", "global 'aaa'")
checkmessage("aaa='2'; b=nil;x=aaa*b", "global 'b'")
checkmessage("aaa={}; x=-aaa", "global 'aaa'")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: short circuit", function (t) {
+test("[test-suite] errors: short circuit", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
checkmessage("a=1; local a,bbbb=2,3; a = math.sin(1) and bbbb(3)",
"local 'bbbb'")
@@ -231,30 +172,18 @@ test("[test-suite] errors: short circuit", function (t) {
checkmessage("print(print < print)", "two function values")
checkmessage("print('10' < 10)", "string with number")
checkmessage("print(10 < '23')", "number with string")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: float->integer conversions", function (t) {
+test("[test-suite] errors: float->integer conversions", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
checkmessage("local a = 2.0^100; x = a << 2", "local a")
checkmessage("local a = 1 >> 2.0^100", "has no integer representation")
@@ -273,30 +202,18 @@ test("[test-suite] errors: float->integer conversions", function (t) {
checkmessage("return 34 >> {}", "table value")
checkmessage("a = 24 // 0", "divide by zero")
checkmessage("a = 1 % 0", "'n%0'")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: passing light userdata instead of full userdata", function (t) {
+test("[test-suite] errors: passing light userdata instead of full userdata", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
_G.D = debug
checkmessage([[
@@ -305,30 +222,18 @@ test("[test-suite] errors: passing light userdata instead of full userdata", fun
D.setuservalue(x, {})
]], "light userdata")
_G.D = nil
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: named objects (field '__name')", function (t) {
+test("[test-suite] errors: named objects (field '__name')", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
checkmessage("math.sin(io.input())", "(number expected, got FILE*)")
@@ -342,57 +247,33 @@ test("[test-suite] errors: named objects (field '__name')", function (t) {
checkmessage("return XX < io.stdin", "My Type with FILE*")
_G.XX = nil
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: global functions", function (t) {
+test("[test-suite] errors: global functions", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
checkmessage("(io.write or print){}", "io.write")
checkmessage("(collectgarbage or print){}", "collectgarbage")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: errors in functions without debug info", function (t) {
+test("[test-suite] errors: errors in functions without debug info", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local f = function (a) return a + 1 end
@@ -407,30 +288,18 @@ test("[test-suite] errors: errors in functions without debug info", function (t)
-- symbolic execution should not get lost
checkerr("^%?:%-1:.*table value", f)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: tests for field accesses after RK limit", function (t) {
+test("[test-suite] errors: tests for field accesses after RK limit", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local t = {}
for i = 1, 1000 do
@@ -442,30 +311,18 @@ test("[test-suite] errors: tests for field accesses after RK limit", function (t
checkmessage("local _ENV=_ENV;"..s.."; a = bbb + 1", "global 'bbb'")
checkmessage(s.."; local t = {}; a = t.bbb + 1", "field 'bbb'")
checkmessage(s.."; local t = {}; t:bbb()", "method 'bbb'")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: global", function (t) {
+test("[test-suite] errors: global", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
checkmessage([[aaa=9
repeat until 3==3
@@ -477,59 +334,35 @@ test("[test-suite] errors: global", function (t) {
3+1>3+1,
{d = x and aaa[x or y]}}
]], "global 'aaa'")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: field", function (t) {
+test("[test-suite] errors: field", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
checkmessage([[
local x,y = {},1
if math.sin(1) == 0 then return 3 end -- return
x.a()]], "field 'a'")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: global insert", function (t) {
+test("[test-suite] errors: global insert", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
checkmessage([[
prefix = nil
@@ -539,86 +372,50 @@ test("[test-suite] errors: global insert", function (t) {
if nil then break end
insert(prefix, a)
end]], "global 'insert'")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: sin", function (t) {
+test("[test-suite] errors: sin", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
checkmessage([[ -- tail call
return math.sin("a")
]], "'sin'")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: concatenate", function (t) {
+test("[test-suite] errors: concatenate", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
checkmessage([[x = print .. "a"]], "concatenate")
checkmessage([[x = "a" .. false]], "concatenate")
checkmessage([[x = {} .. 2]], "concatenate")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: unknown global", function (t) {
+test("[test-suite] errors: unknown global", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
checkmessage([[
local Var
@@ -627,30 +424,18 @@ test("[test-suite] errors: unknown global", function (t) {
end
main()
]], "global 'NoSuchName'")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: __index", function (t) {
+test("[test-suite] errors: __index", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
a = {}; setmetatable(a, {__index = string})
checkmessage("a:sub()", "bad self")
@@ -659,30 +444,18 @@ test("[test-suite] errors: __index", function (t) {
checkmessage("table.sort({1,2,3}, table.sort)", "'table.sort'")
checkmessage("string.gsub('s', 's', setmetatable)", "'setmetatable'")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: tests for errors in coroutines", function (t) {
+test("[test-suite] errors: tests for errors in coroutines", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function f (n)
local c = coroutine.create(f)
@@ -695,30 +468,18 @@ test("[test-suite] errors: tests for errors in coroutines", function (t) {
f = coroutine.wrap(function () table.sort({1,2,3}, coroutine.yield) end)
checkerr("yield across", f)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: testing size of 'source' info", function (t) {
+test("[test-suite] errors: testing size of 'source' info", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
idsize = 60 - 1
local function checksize (source)
@@ -734,30 +495,18 @@ test("[test-suite] errors: testing size of 'source' info", function (t) {
checksize("=" .. string.rep("x", i)) -- exact sources
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: testing line error", function (t) {
+test("[test-suite] errors: testing line error", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function lineerror (s, l)
local err,msg = pcall(load(s))
@@ -811,30 +560,18 @@ test("[test-suite] errors: testing line error", function (t) {
X=0;lineerror((p), nil)
X=1;lineerror((p), 2)
X=2;lineerror((p), 1)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: several tests that exhaust the Lua stack", function (t) {
+test("[test-suite] errors: several tests that exhaust the Lua stack", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
C = 0
local l = debug.getinfo(1, "l").currentline; function y () C=C+1; y() end
@@ -846,30 +583,18 @@ test("[test-suite] errors: several tests that exhaust the Lua stack", function (
assert(checkstackmessage(doit('y()')))
assert(checkstackmessage(doit('y()')))
assert(checkstackmessage(doit('y()')))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: error lines in stack overflow", function (t) {
+test("[test-suite] errors: error lines in stack overflow", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
C = 0
local l = debug.getinfo(1, "l").currentline; function y () C=C+1; y() end
@@ -889,30 +614,18 @@ test("[test-suite] errors: error lines in stack overflow", function (t) {
i = i+1
end
assert(i > 15)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: error in error handling", function (t) {
+test("[test-suite] errors: error in error handling", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local res, msg = xpcall(error, error)
assert(not res and type(msg) == 'string')
@@ -926,30 +639,18 @@ test("[test-suite] errors: error in error handling", function (t) {
end
end
f(3)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: too many results", function (t) {
+test("[test-suite] errors: too many results", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function loop (x,y,z) return 1 + loop(x, y, z) end
@@ -965,30 +666,18 @@ test("[test-suite] errors: too many results", function (t) {
for i = 999900, 1000000, 1 do table.unpack({}, 1, i) end
end
checkerr("too many results", f)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: non string messages", function (t) {
+test("[test-suite] errors: non string messages", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
-- non string messages
@@ -1023,59 +712,35 @@ test("[test-suite] errors: non string messages", function (t) {
res, msg = pcall(assert)
assert(not res and string.find(msg, "value expected"))
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadbuffer(L, to_luastring(prefix + luaCode), null, to_luastring("@errors.lua"));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadbuffer(L, to_luastring(prefix + luaCode), null, to_luastring("@errors.lua")) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: xpcall with arguments", function (t) {
+test("[test-suite] errors: xpcall with arguments", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
a, b, c = xpcall(string.find, error, "alo", "al")
assert(a and b == 1 and c == 2)
a, b, c = xpcall(string.find, function (x) return {} end, true, "al")
assert(not a and type(b) == "table" and c == nil)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: testing tokens in error messages", function (t) {
+test("[test-suite] errors: testing tokens in error messages", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
checksyntax("syntax error", "", "error", 1)
checksyntax("1.000", "", "1.000", 1)
@@ -1083,85 +748,49 @@ test("[test-suite] errors: testing tokens in error messages", function (t) {
checksyntax("'aa'", "", "'aa'", 1)
checksyntax("while << do end", "", "<<", 1)
checksyntax("for >> do end", "", ">>", 1)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: test invalid non-printable char in a chunk", function (t) {
+test("[test-suite] errors: test invalid non-printable char in a chunk", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
checksyntax("a\\1a = 1", "", "<\\\\1>", 1)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: test 255 as first char in a chunk", function (t) {
+test("[test-suite] errors: test 255 as first char in a chunk", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
checksyntax("\\255a = 1", "", "<\\\\255>", 1)
doit('I = load("a=9+"); a=3')
assert(a==3 and I == nil)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: lots of errors", function (t) {
+test("[test-suite] errors: lots of errors", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
lim = 1000
if _soft then lim = 100 end
@@ -1169,30 +798,18 @@ test("[test-suite] errors: lots of errors", function (t) {
doit('a = ')
doit('a = 4+nil')
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: testing syntax limits", function (t) {
+test("[test-suite] errors: testing syntax limits", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local maxClevel = 200 -- LUAI_MAXCCALLS (in llimits.h)
@@ -1216,30 +833,18 @@ test("[test-suite] errors: testing syntax limits", function (t) {
testrep("local a; a=", "a^", "a", "")
checkmessage("a = f(x" .. string.rep(",x", 260) .. ")", "too many registers")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: upvalues limit", function (t) {
+test("[test-suite] errors: upvalues limit", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local lim = 127
local s = "local function fooA ()\\n local "
@@ -1262,30 +867,18 @@ test("[test-suite] errors: upvalues limit", function (t) {
local a,b = load(s)
assert(c > 255 and string.find(b, "too many upvalues") and
string.find(b, "line 5"))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] errors: local variables limit", function (t) {
+test("[test-suite] errors: local variables limit", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
s = "\\nfunction foo ()\\n local "
for j = 1,300 do
@@ -1294,24 +887,9 @@ test("[test-suite] errors: local variables limit", function (t) {
s = s.."b\\n"
local a,b = load(s)
assert(string.find(b, "line 2") and string.find(b, "too many local variables"))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
diff --git a/tests/test-suite/events.js b/test/test-suite/events.test.js
index 143bdf5..67faad6 100644
--- a/tests/test-suite/events.js
+++ b/test/test-suite/events.test.js
@@ -1,15 +1,16 @@
"use strict";
-const test = require('tape');
-
-const lua = require('../../src/lua.js');
+const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
-const lualib = require('../../src/lualib.js');
+const lualib = require('../../src/lualib.js');
const {to_luastring} = require("../../src/fengaricore.js");
-const ltests = require('./ltests.js');
+const ltests = require('./ltests.js');
+
+test("[test-suite] events: testing metatable", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
-test("[test-suite] events: testing metatable", function (t) {
let luaCode = `
X = 20; B = 30
@@ -181,30 +182,18 @@ test("[test-suite] events: testing metatable", function (t) {
assert(cap[0] == "shl" and cap[1] == a and cap[2] == 3)
assert(1.5 >> a == 1.5)
assert(cap[0] == "shr" and cap[1] == 1.5 and cap[2] == a)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] events: test for rawlen", function (t) {
+test("[test-suite] events: test for rawlen", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
t = setmetatable({1,2,3}, {__len = function () return 10 end})
assert(#t == 10 and rawlen(t) == 3)
@@ -215,30 +204,18 @@ test("[test-suite] events: test for rawlen", function (t) {
-- rawlen for long strings
assert(rawlen(string.rep('a', 1000)) == 1000)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] events: test comparison", function (t) {
+test("[test-suite] events: test comparison", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
t = {}
t.__lt = function (a,b,c)
@@ -276,30 +253,18 @@ test("[test-suite] events: test comparison", function (t) {
end
test() -- retest comparisons, now using both 'lt' and 'le'
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] events: test 'partial order'", function (t) {
+test("[test-suite] events: test 'partial order'", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
t = {}
@@ -359,30 +324,18 @@ test("[test-suite] events: test 'partial order'", function (t) {
-- '__eq' is not used for table accesses
t[Set{1,3,5}] = 1
assert(t[Set{1,3,5}] == nil)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] events: __eq between userdata", function (t) {
+test("[test-suite] events: __eq between userdata", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
T = require('T')
@@ -402,32 +355,19 @@ test("[test-suite] events: __eq between userdata", function (t) {
assert(u1 == u3 and u3 == u1 and u1 ~= u2)
assert(u2 == u1 and u2 == u3 and u3 == u2)
assert(u2 ~= {}) -- different types cannot be equal
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] events: concat", function (t) {
+test("[test-suite] events: concat", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
t = {}
@@ -454,32 +394,19 @@ test("[test-suite] events: concat", function (t) {
assert(getmetatable(x) == t and x.val == 'cd')
x = 0 .."a".."b"..c..d.."e".."f".."g"
assert(x.val == "0abcdefg")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] events: concat metamethod x numbers (bug in 5.1.1)", function (t) {
+test("[test-suite] events: concat metamethod x numbers (bug in 5.1.1)", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
c = {}
local x
@@ -489,32 +416,19 @@ test("[test-suite] events: concat metamethod x numbers (bug in 5.1.1)", function
end})
assert(c..5 == c and 5 .. c == c)
assert(4 .. c .. 5 == c and 4 .. 5 .. 6 .. 7 .. c == c)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] events: test comparison compatibilities", function (t) {
+test("[test-suite] events: test comparison compatibilities", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local t1, t2, c, d
t1 = {}; c = {}; setmetatable(c, t1)
@@ -528,32 +442,19 @@ test("[test-suite] events: test comparison compatibilities", function (t) {
t2.__lt = t1.__lt
setmetatable(d, t2)
assert(c == d and c < d and not(d <= c))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] events: test for several levels of callstest for several levels of calls", function (t) {
+test("[test-suite] events: test for several levels of callstest for several levels of calls", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local i
local tt = {
@@ -572,32 +473,19 @@ test("[test-suite] events: test for several levels of callstest for several leve
i = 0
x = c(3,4,5)
assert(i == 3 and x[1] == 3 and x[3] == 5)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] events: __index on _ENV", function (t) {
+test("[test-suite] events: __index on _ENV", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local _g = _G
_ENV = setmetatable({}, {__index=function (_,k) return _g[k] end})
@@ -605,32 +493,19 @@ test("[test-suite] events: __index on _ENV", function (t) {
a = {}
rawset(a, "x", 1, 2, 3)
assert(a.x == 1 and rawget(a, "x", 3) == 1)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] events: testing metatables for basic types", function (t) {
+test("[test-suite] events: testing metatables for basic types", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
mt = {__index = function (a,b) return a+b end,
__len = function (x) return math.floor(x) end}
@@ -660,62 +535,36 @@ test("[test-suite] events: testing metatables for basic types", function (t) {
assert(getmetatable(nil) == nil)
debug.setmetatable(nil, {})
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] events: loops in delegation", function (t) {
+test("[test-suite] events: loops in delegation", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
a = {}; setmetatable(a, a); a.__index = a; a.__newindex = a
assert(not pcall(function (a,b) return a[b] end, a, 10))
assert(not pcall(function (a,b,c) a[b] = c end, a, 10, true))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] events: bug in 5.1", function (t) {
+test("[test-suite] events: bug in 5.1", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
T, K, V = nil
grandparent = {}
@@ -728,26 +577,10 @@ test("[test-suite] events: bug in 5.1", function (t) {
child = setmetatable({}, parent)
child.foo = 10 --> CRASH (on some machines)
assert(T == parent and K == "foo" and V == 10)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- ltests.luaopen_tests(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ ltests.luaopen_tests(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
diff --git a/tests/test-suite/goto.js b/test/test-suite/goto.test.js
index dc52c73..17e0397 100644
--- a/tests/test-suite/goto.js
+++ b/test/test-suite/goto.test.js
@@ -1,13 +1,14 @@
"use strict";
-const test = require('tape');
-
-const lua = require('../../src/lua.js');
+const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
-const lualib = require('../../src/lualib.js');
+const lualib = require('../../src/lualib.js');
const {to_luastring} = require("../../src/fengaricore.js");
-test("[test-suite] goto: error messages", function (t) {
+test("[test-suite] goto: error messages", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function errmsg (code, m)
local st, msg = load(code)
@@ -44,30 +45,18 @@ test("[test-suite] goto: error messages", function (t) {
::cont::
until xuxu < x
]], "local 'xuxu'")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] goto", function (t) {
+test("[test-suite] goto", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
-- simple gotos
local x
@@ -123,30 +112,18 @@ test("[test-suite] goto", function (t) {
local x
::l1:: ; ::l2:: ;;
else end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] goto: to repeat a label in a different function is OK", function (t) {
+test("[test-suite] goto: to repeat a label in a different function is OK", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function foo ()
local a = {}
@@ -163,30 +140,18 @@ test("[test-suite] goto: to repeat a label in a different function is OK", funct
end
::l6:: foo()
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] goto: bug in 5.2 -> 5.3.2", function (t) {
+test("[test-suite] goto: bug in 5.2 -> 5.3.2", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do -- bug in 5.2 -> 5.3.2
local x
@@ -202,30 +167,18 @@ test("[test-suite] goto: bug in 5.2 -> 5.3.2", function (t) {
end
assert(x == 2 and y == true)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] goto: testing closing of upvalues", function (t) {
+test("[test-suite] goto: testing closing of upvalues", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function foo ()
local t = {}
@@ -287,30 +240,18 @@ test("[test-suite] goto: testing closing of upvalues", function (t) {
== (i == j))
end
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] goto: testing if x goto optimizations", function (t) {
+test("[test-suite] goto: testing if x goto optimizations", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function testG (a)
if a == 1 then
@@ -341,24 +282,9 @@ test("[test-suite] goto: testing if x goto optimizations", function (t) {
assert(testG(3) == "3")
assert(testG(4) == 5)
assert(testG(5) == 10)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
diff --git a/tests/test-suite/literals.js b/test/test-suite/literals.test.js
index 6e3205e..3e9307b 100644
--- a/tests/test-suite/literals.js
+++ b/test/test-suite/literals.test.js
@@ -1,74 +1,51 @@
"use strict";
-const test = require('tape');
-
-const lua = require('../../src/lua.js');
+const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
-const lualib = require('../../src/lualib.js');
+const lualib = require('../../src/lualib.js');
const {to_luastring} = require("../../src/fengaricore.js");
const dostring = `
local function dostring (x) return assert(load(x), "")() end
`;
-test("[test-suite] literals: dostring", function (t) {
+test("[test-suite] literals: dostring", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
dostring("x \\v\\f = \\t\\r 'a\\0a' \\v\\f\\f")
assert(x == 'a\\0a' and string.len(x) == 3)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
// TODO: bell character '\a' in JS is parsed as 'a'
-test("[test-suite] literals: escape sequences", function (t) {
+test("[test-suite] literals: escape sequences", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert('\\n\\"\\'\\\\' == [[
"'\\]])
assert(string.find("\\b\\f\\n\\r\\t\\v", "^%c%c%c%c%c%c$"))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] literals: assume ASCII just for tests", function (t) {
+test("[test-suite] literals: assume ASCII just for tests", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert("\\09912" == 'c12')
assert("\\99ab" == 'cab')
@@ -77,30 +54,18 @@ test("[test-suite] literals: assume ASCII just for tests", function (t) {
assert('\\0\\0\\0alo' == '\\0' .. '\\0\\0' .. 'alo')
assert(010 .. 020 .. -030 == "1020-30")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] literals: hexadecimal escapes", function (t) {
+test("[test-suite] literals: hexadecimal escapes", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert("\\x00\\x05\\x10\\x1f\\x3C\\xfF\\xe8" == "\\0\\5\\16\\31\\60\\255\\232")
@@ -124,30 +89,18 @@ assert("abc\\z
def\\z
ghi\\z
" == 'abcdefghi')
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] literals: UTF-8 sequences", function (t) {
+test("[test-suite] literals: UTF-8 sequences", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert("\\u{0}\\u{00000000}\\x00\\0" == string.char(0, 0, 0, 0))
@@ -162,30 +115,18 @@ test("[test-suite] literals: UTF-8 sequences", function (t) {
-- limits for 4-byte sequences
assert("\\u{10000}\\u{10FFFF}" == "\\xF0\\x90\\x80\\x80\\z\\xF4\\x8F\\xBF\\xBF")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] literals: Error in escape sequences", function (t) {
+test("[test-suite] literals: Error in escape sequences", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function lexerror (s, err)
local st, msg = load('return ' .. s, '')
@@ -228,30 +169,18 @@ test("[test-suite] literals: Error in escape sequences", function (t) {
lexerror("'alo \\\\z \\n\\n", "<eof>")
lexerror("'alo \\\\z", "<eof>")
lexerror([['alo \\98]], "<eof>")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] literals: valid characters in variable names", function (t) {
+test("[test-suite] literals: valid characters in variable names", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
for i = 0, 255 do
local s = string.char(i)
@@ -259,30 +188,18 @@ test("[test-suite] literals: valid characters in variable names", function (t) {
assert(not string.find(s, "[a-zA-Z_0-9]") ==
not load("a" .. s .. "1 = 1", ""))
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] literals: long variable names", function (t) {
+test("[test-suite] literals: long variable names", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
var1 = string.rep('a', 15000) .. '1'
var2 = string.rep('a', 15000) .. '2'
@@ -294,56 +211,32 @@ test("[test-suite] literals: long variable names", function (t) {
local f = dostring(prog)
assert(_G[var1] == 5 and _G[var2] == 6 and f() == -1)
var1, var2, f = nil
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] literals: escapes", function (t) {
+test("[test-suite] literals: escapes", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `assert("\\n\\t" == [[\n\n\t]])
assert([[\n\n $debug]] == "\\n $debug")
-assert([[ [ ]] ~= [[ ] ]])`, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+assert([[ [ ]] ~= [[ ] ]])`;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] literals: long strings", function (t) {
+test("[test-suite] literals: long strings", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `b = "001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789001234567890123456789012345678901234567891234567890123456789012345678901234567890012345678901234567890123456789012345678912345678901234567890123456789012345678900123456789012345678901234567890123456789123456789012345678901234567890123456789"
assert(string.len(b) == 960)
prog = [=[
@@ -395,30 +288,18 @@ assert(x)
prog = nil
a = nil
-b = nil`, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+b = nil`;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] literals: testing line ends", function (t) {
+test("[test-suite] literals: testing line ends", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `prog = [[
a = 1 -- a comment
b = 2
@@ -437,30 +318,18 @@ for _, n in pairs{"\\n", "\\r", "\\n\\r", "\\r\\n"} do
local prog, nn = string.gsub(prog, "\\n", n)
assert(dostring(prog) == nn)
assert(_G.x == "hi\\n" and _G.y == "\\nhello\\r\\n\\n")
-end`, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+end`;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] literals: testing comments and strings with long brackets", function (t) {
+test("[test-suite] literals: testing comments and strings with long brackets", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `a = [==[]=]==]
assert(a == "]=")
@@ -479,31 +348,18 @@ x y z [==[ blu foo
]==
]
]=]==]
-error error]=]===]`, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
-
+error error]=]===]`;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] literals: generate all strings of four of these chars", function (t) {
+test("[test-suite] literals: generate all strings of four of these chars", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `local x = {"=", "[", "]", "\\n"}
local len = 4
local function gen (c, n)
@@ -517,84 +373,42 @@ end
for s in coroutine.wrap(function () gen("", len) end) do
assert(s == load("return [====[\\n"..s.."]====]", "")())
-end`, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
-
+end`;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] literals: testing %q x line ends", function (t) {
+test("[test-suite] literals: testing %q x line ends", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local s = "a string with \\r and \\n and \\r\\n and \\n\\r"
local c = string.format("return %q", s)
assert(assert(load(c))() == s)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] literals: testing errors", function (t) {
+test("[test-suite] literals: testing errors", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(not load"a = 'non-ending string")
assert(not load"a = 'non-ending string\\n'")
assert(not load"a = '\\\\345'")
assert(not load"a = [=x]")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(dostring + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
diff --git a/tests/test-suite/locals.js b/test/test-suite/locals.test.js
index d1dc3e4..2701519 100644
--- a/tests/test-suite/locals.js
+++ b/test/test-suite/locals.test.js
@@ -1,13 +1,14 @@
"use strict";
-const test = require('tape');
-
-const lua = require('../../src/lua.js');
+const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
-const lualib = require('../../src/lualib.js');
+const lualib = require('../../src/lualib.js');
const {to_luastring} = require("../../src/fengaricore.js");
-test('[test-suite] locals: bug in 5.1', function (t) {
+test('[test-suite] locals: bug in 5.1', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function f(x) x = nil; return x end
assert(f(10) == nil)
@@ -17,30 +18,18 @@ test('[test-suite] locals: bug in 5.1', function (t) {
local function f(x) x = nil; local y; return x, y end
assert(f(10) == nil and select(2, f(20)) == nil)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test('[test-suite] locals: local scope', function (t) {
+test('[test-suite] locals: local scope', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local i = 10
@@ -89,26 +78,11 @@ test('[test-suite] locals: local scope', function (t) {
f(2)
assert(type(f) == 'function')
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
@@ -121,7 +95,10 @@ const getenv = `
`;
-test('[test-suite] locals: test for global table of loaded chunks', function (t) {
+test('[test-suite] locals: test for global table of loaded chunks', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(getenv(load"a=3") == _G)
local c = {}; local f = load("a = 3", nil, nil, c)
@@ -129,30 +106,18 @@ test('[test-suite] locals: test for global table of loaded chunks', function (t)
assert(c.a == nil)
f()
assert(c.a == 3)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(getenv + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(getenv + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test('[test-suite] locals: old test for limits for special instructions (now just a generic test)', function (t) {
+test('[test-suite] locals: old test for limits for special instructions (now just a generic test)', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local i = 2
@@ -172,30 +137,18 @@ test('[test-suite] locals: old test for limits for special instructions (now jus
p = 2 * p; i = i + 1
until p <= 0
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test('[test-suite] locals: testing lexical environments', function (t) {
+test('[test-suite] locals: testing lexical environments', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(_ENV == _G)
@@ -226,24 +179,9 @@ test('[test-suite] locals: testing lexical environments', function (t) {
end
assert(x==20)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(getenv + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(getenv + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
diff --git a/tests/test-suite/ltests.js b/test/test-suite/ltests.js
index 6fc086c..6fc086c 100644
--- a/tests/test-suite/ltests.js
+++ b/test/test-suite/ltests.js
diff --git a/tests/test-suite/math.js b/test/test-suite/math.test.js
index 1e54772..9cf4e21 100644
--- a/tests/test-suite/math.js
+++ b/test/test-suite/math.test.js
@@ -1,10 +1,8 @@
"use strict";
-const test = require('tape');
-
-const lua = require('../../src/lua.js');
+const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
-const lualib = require('../../src/lualib.js');
+const lualib = require('../../src/lualib.js');
const {to_luastring} = require("../../src/fengaricore.js");
const prefix = `
@@ -54,34 +52,25 @@ const prefix = `
end
`;
-test("[test-suite] math: int bits", function (t) {
+test("[test-suite] math: int bits", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(minint == 1 << (intbits - 1))
assert(maxint == minint - 1)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: number of bits in the mantissa of a floating-point number", function (t) {
+test("[test-suite] math: number of bits in the mantissa of a floating-point number", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(isNaN(0/0))
assert(not isNaN(1/0))
@@ -91,36 +80,24 @@ test("[test-suite] math: number of bits in the mantissa of a floating-point numb
local x = 2.0^floatbits
assert(x > x - 1.0 and x == x + 1.0)
- print(string.format("%d-bit integers, %d-bit (mantissa) floats",
- intbits, floatbits))
+ -- print(string.format("%d-bit integers, %d-bit (mantissa) floats",
+ -- intbits, floatbits))
end
assert(math.type(0) == "integer" and math.type(0.0) == "float"
and math.type("10") == nil)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: basic float notation", function (t) {
+test("[test-suite] math: basic float notation", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(0e12 == 0 and .0 == 0 and 0. == 0 and .2e2 == 20 and 2.E-1 == 0.2)
@@ -161,87 +138,51 @@ test("[test-suite] math: basic float notation", function (t) {
a,b = math.modf(minint)
assert(eqT(a, minint) and eqT(b, 0.0))
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: math.huge", function (t) {
+test("[test-suite] math: math.huge", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(math.huge > 10e30)
assert(-math.huge < -10e30)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: integer arithmetic", function (t) {
+test("[test-suite] math: integer arithmetic", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(minint < minint + 1)
assert(maxint - 1 < maxint)
assert(0 - minint == minint)
assert(minint * minint == 0)
assert(maxint * maxint * maxint == maxint)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: testing floor division and conversions", function (t) {
+test("[test-suite] math: testing floor division and conversions", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
for _, i in pairs{-16, -15, -3, -2, -1, 0, 1, 2, 3, 15} do
for _, j in pairs{-16, -15, -3, -2, -1, 1, 2, 3, 15} do
@@ -273,30 +214,18 @@ test("[test-suite] math: testing floor division and conversions", function (t) {
assert(minint // -1 == -minint)
assert(minint // -2 == 2^(intbits - 2))
assert(maxint // -1 == -maxint)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: negative exponents", function (t) {
+test("[test-suite] math: negative exponents", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
assert(2^-3 == 1 / 2^3)
@@ -310,30 +239,18 @@ test("[test-suite] math: negative exponents", function (t) {
end
end
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: comparison between floats and integers (border cases)", function (t) {
+test("[test-suite] math: comparison between floats and integers (border cases)", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
if floatbits < intbits then
assert(2.0^floatbits == (1 << floatbits))
@@ -350,30 +267,18 @@ test("[test-suite] math: comparison between floats and integers (border cases)",
assert(maxint + 0.0 == 2.0^(intbits - 1) - 1.0)
assert(minint + 0.0 == minint)
assert(minint + 0.0 == -2.0^(intbits - 1))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: order between floats and integers", function (t) {
+test("[test-suite] math: order between floats and integers", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(minint == 1 << (intbits - 1))
assert(maxint == minint - 1)
@@ -399,90 +304,81 @@ test("[test-suite] math: order between floats and integers", function (t) {
assert(minint <= -2^(intbits - 1))
assert(-2^(intbits - 1) <= minint)
end
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
+});
- if floatbits < intbits then
- print("testing order (floats cannot represent all integers)")
- local fmax = 2^floatbits
- local ifmax = fmax | 0
- assert(fmax < ifmax + 1)
- assert(fmax - 1 < ifmax)
- assert(-(fmax - 1) > -ifmax)
- assert(not (fmax <= ifmax - 1))
- assert(-fmax > -(ifmax + 1))
- assert(not (-fmax >= -(ifmax - 1)))
-
- assert(fmax/2 - 0.5 < ifmax//2)
- assert(-(fmax/2 - 0.5) > -ifmax//2)
-
- assert(maxint < 2^intbits)
- assert(minint > -2^intbits)
- assert(maxint <= 2^intbits)
- assert(minint >= -2^intbits)
- else
- print("testing order (floats can represent all integers)")
- assert(maxint < maxint + 1.0)
- assert(maxint < maxint + 0.5)
- assert(maxint - 1.0 < maxint)
- assert(maxint - 0.5 < maxint)
- assert(not (maxint + 0.0 < maxint))
- assert(maxint + 0.0 <= maxint)
- assert(not (maxint < maxint + 0.0))
- assert(maxint + 0.0 <= maxint)
- assert(maxint <= maxint + 0.0)
- assert(not (maxint + 1.0 <= maxint))
- assert(not (maxint + 0.5 <= maxint))
- assert(not (maxint <= maxint - 1.0))
- assert(not (maxint <= maxint - 0.5))
-
- assert(minint < minint + 1.0)
- assert(minint < minint + 0.5)
- assert(minint <= minint + 0.5)
- assert(minint - 1.0 < minint)
- assert(minint - 1.0 <= minint)
- assert(not (minint + 0.0 < minint))
- assert(not (minint + 0.5 < minint))
- assert(not (minint < minint + 0.0))
- assert(minint + 0.0 <= minint)
- assert(minint <= minint + 0.0)
- assert(not (minint + 1.0 <= minint))
- assert(not (minint + 0.5 <= minint))
- assert(not (minint <= minint - 1.0))
- end
-
- do
- local NaN = 0/0
- assert(not (NaN < 0))
- assert(not (NaN > minint))
- assert(not (NaN <= -9))
- assert(not (NaN <= maxint))
- assert(not (NaN < maxint))
- assert(not (minint <= NaN))
- assert(not (minint < NaN))
- end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
- }, "Lua program loaded without error");
+test("[test-suite] math: testing order (floats can represent all integers)", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
- t.doesNotThrow(function () {
+ let luaCode = `
+ assert(floatbits >= intbits)
+
+ assert(maxint < maxint + 1.0)
+ assert(maxint < maxint + 0.5)
+ assert(maxint - 1.0 < maxint)
+ assert(maxint - 0.5 < maxint)
+ assert(not (maxint + 0.0 < maxint))
+ assert(maxint + 0.0 <= maxint)
+ assert(not (maxint < maxint + 0.0))
+ assert(maxint + 0.0 <= maxint)
+ assert(maxint <= maxint + 0.0)
+ assert(not (maxint + 1.0 <= maxint))
+ assert(not (maxint + 0.5 <= maxint))
+ assert(not (maxint <= maxint - 1.0))
+ assert(not (maxint <= maxint - 0.5))
+
+ assert(minint < minint + 1.0)
+ assert(minint < minint + 0.5)
+ assert(minint <= minint + 0.5)
+ assert(minint - 1.0 < minint)
+ assert(minint - 1.0 <= minint)
+ assert(not (minint + 0.0 < minint))
+ assert(not (minint + 0.5 < minint))
+ assert(not (minint < minint + 0.0))
+ assert(minint + 0.0 <= minint)
+ assert(minint <= minint + 0.0)
+ assert(not (minint + 1.0 <= minint))
+ assert(not (minint + 0.5 <= minint))
+ assert(not (minint <= minint - 1.0))
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
+});
- lua.lua_call(L, 0, -1);
- }, "Lua program ran without error");
+test("[test-suite] math: NaN order", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+ let luaCode = `
+ local NaN = 0/0
+ assert(not (NaN < 0))
+ assert(not (NaN > minint))
+ assert(not (NaN <= -9))
+ assert(not (NaN <= maxint))
+ assert(not (NaN < maxint))
+ assert(not (minint <= NaN))
+ assert(not (minint < NaN))
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: avoiding errors at compile time", function (t) {
+test("[test-suite] math: avoiding errors at compile time", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
checkcompt("divide by zero", "return 2 // 0")
checkcompt(msgf2i, "return 2.3 >> 0")
@@ -490,29 +386,17 @@ test("[test-suite] math: avoiding errors at compile time", function (t) {
checkcompt("field 'huge'", "return math.huge << 1")
checkcompt(msgf2i, ("return 1 | 2.0^%d"):format(intbits - 1))
checkcompt(msgf2i, "return 2.3 ~ '0.0'")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: testing overflow errors when converting from float to integer (runtime)", function (t) {
+test("[test-suite] math: testing overflow errors when converting from float to integer (runtime)", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function f2i (x) return x | x end
checkerror(msgf2i, f2i, math.huge) -- +inf
@@ -543,59 +427,35 @@ test("[test-suite] math: testing overflow errors when converting from float to i
-- 'minint' should be representable as a float no matter the precision
assert(f2i(minint + 0.0) == minint)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: testing numeric strings", function (t) {
+test("[test-suite] math: testing numeric strings", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert("2" + 1 == 3)
assert("2 " + 1 == 3)
assert(" -2 " + 1 == -1)
assert(" -0xa " + 1 == -9)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: Literal integer Overflows (new behavior in 5.3.3)", function (t) {
+test("[test-suite] math: Literal integer Overflows (new behavior in 5.3.3)", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
-- no overflows
@@ -630,59 +490,35 @@ test("[test-suite] math: Literal integer Overflows (new behavior in 5.3.3)", fun
assert(eqT(10000000000000000000000.0, 10000000000000000000000))
assert(eqT(-10000000000000000000000.0, -10000000000000000000000))
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: 'tonumber' with numbers", function (t) {
+test("[test-suite] math: 'tonumber' with numbers", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(tonumber(3.4) == 3.4)
assert(eqT(tonumber(3), 3))
assert(eqT(tonumber(maxint), maxint) and eqT(tonumber(minint), minint))
assert(tonumber(1/0) == 1/0)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: 'tonumber' with strings", function (t) {
+test("[test-suite] math: 'tonumber' with strings", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(tonumber("0") == 0)
assert(tonumber("") == nil)
@@ -721,30 +557,18 @@ test("[test-suite] math: 'tonumber' with strings", function (t) {
local i10 = i2 * i2 * i2 * i2 * i2 -- i^10
assert(tonumber('\\t10000000000\\t', i) == i10)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: tests with very long numerals", function (t) {
+test("[test-suite] math: tests with very long numerals", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(tonumber("0x"..string.rep("f", 13)..".0") == 2.0^(4*13) - 1)
assert(tonumber("0x"..string.rep("f", 150)..".0") == 2.0^(4*150) - 1)
@@ -759,30 +583,18 @@ test("[test-suite] math: tests with very long numerals", function (t) {
assert(tonumber('0xe03' .. string.rep('0', 1000) .. 'p-4000') == 3587.0)
assert(tonumber('0x.' .. string.rep('0', 1000) .. '74p4004') == 0x7.4)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: testing 'tonumber' for invalid formats", function (t) {
+test("[test-suite] math: testing 'tonumber' for invalid formats", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function f (...)
if select('#', ...) == 1 then
@@ -815,30 +627,18 @@ test("[test-suite] math: testing 'tonumber' for invalid formats", function (t) {
assert(f(tonumber('e1')) == nil)
assert(f(tonumber('e 1')) == nil)
assert(f(tonumber(' 3.4.5 ')) == nil)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: testing 'tonumber' for invalid hexadecimal formats", function (t) {
+test("[test-suite] math: testing 'tonumber' for invalid hexadecimal formats", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(tonumber('0x') == nil)
assert(tonumber('x') == nil)
@@ -852,30 +652,18 @@ test("[test-suite] math: testing 'tonumber' for invalid hexadecimal formats", fu
assert(tonumber('-0xaaP ') == nil) -- no exponent
assert(tonumber('0x0.51p') == nil)
assert(tonumber('0x5p+-2') == nil)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: testing hexadecimal numerals", function (t) {
+test("[test-suite] math: testing hexadecimal numerals", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(0x10 == 16 and 0xfff == 2^12 - 1 and 0XFB == 251)
assert(0x0p12 == 0 and 0x.0p-3 == 0)
@@ -886,30 +674,18 @@ test("[test-suite] math: testing hexadecimal numerals", function (t) {
-- possible confusion with decimal exponent
assert(0E+1 == 0 and 0xE+1 == 15 and 0xe-1 == 13)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: floating hexas", function (t) {
+test("[test-suite] math: floating hexas", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(tonumber(' 0x2.5 ') == 0x25/16)
assert(tonumber(' -0x2.5 ') == -0x25/16)
@@ -934,30 +710,18 @@ test("[test-suite] math: floating hexas", function (t) {
assert(0.123456 > 0.123455)
assert(tonumber('+1.23E18') == 1.23*10.0^18)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: testing order operators", function (t) {
+test("[test-suite] math: testing order operators", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(not(1<1) and (1<2) and not(2<1))
assert(not('a'<'a') and ('a'<'b') and not('b'<'a'))
@@ -968,30 +732,18 @@ test("[test-suite] math: testing order operators", function (t) {
assert((1>=1) and not(1>=2) and (2>=1))
assert(('a'>='a') and not('a'>='b') and ('b'>='a'))
assert(1.3 < 1.4 and 1.3 <= 1.4 and not (1.3 < 1.3) and 1.3 <= 1.3)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: testing mod operator", function (t) {
+test("[test-suite] math: testing mod operator", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(eqT(-4 % 3, 2))
assert(eqT(4 % -3, -2))
@@ -1009,30 +761,18 @@ test("[test-suite] math: testing mod operator", function (t) {
assert(minint % -1 == 0)
assert(minint % -2 == 0)
assert(maxint % -2 == -1)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: non-portable tests because Windows C library cannot compute fmod(1, huge) correctly", function (t) {
+test("[test-suite] math: non-portable tests because Windows C library cannot compute fmod(1, huge) correctly", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function anan (x) assert(isNaN(x)) end -- assert Not a Number
anan(0.0 % 0)
@@ -1046,30 +786,18 @@ test("[test-suite] math: non-portable tests because Windows C library cannot com
assert(1e30 % -math.huge == -math.huge)
assert(-1 % math.huge == math.huge)
assert(-1 % -math.huge == -1)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: testing unsigned comparisons", function (t) {
+test("[test-suite] math: testing unsigned comparisons", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(math.ult(3, 4))
assert(not math.ult(4, 4))
@@ -1102,58 +830,34 @@ test("[test-suite] math: testing unsigned comparisons", function (t) {
assert(tonumber(' 1.3e-2 ') == 1.3e-2)
assert(tonumber(' -1.00000000000001 ') == -1.00000000000001)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: testing constant limits", function (t) {
+test("[test-suite] math: testing constant limits", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(8388609 + -8388609 == 0)
assert(8388608 + -8388608 == 0)
assert(8388607 + -8388607 == 0)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: testing floor & ceil", function (t) {
+test("[test-suite] math: testing floor & ceil", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
assert(eqT(math.floor(3.4), 3))
@@ -1197,30 +901,18 @@ test("[test-suite] math: testing floor & ceil", function (t) {
assert(math.tointeger({}) == nil)
assert(math.tointeger(0/0) == nil) -- NaN
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: testing fmod for integers", function (t) {
+test("[test-suite] math: testing fmod for integers", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
for i = -6, 6 do
for j = -6, 6 do
@@ -1241,30 +933,18 @@ test("[test-suite] math: testing fmod for integers", function (t) {
assert(eqT(math.fmod(maxint - 1, maxint), maxint - 1))
checkerror("zero", math.fmod, 3, 0)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: testing max/min", function (t) {
+test("[test-suite] math: testing max/min", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
checkerror("value expected", math.max)
@@ -1281,61 +961,36 @@ test("[test-suite] math: testing max/min", function (t) {
assert(eqT(math.min(maxint, maxint - 1), maxint - 1))
assert(eqT(math.min(maxint - 2, maxint, maxint - 1), maxint - 2))
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: testing implicit convertions", function (t) {
+test("[test-suite] math: testing implicit convertions", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a,b = '10', '20'
assert(a*b == 200 and a+b == 30 and a-b == -10 and a/b == 0.5 and -b == -20)
assert(a == '10' and b == '20')
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: testing -0 and NaN", function (t) {
+test("[test-suite] math: testing -0 and NaN", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
- print("testing -0 and NaN")
local mz, z = -0.0, 0.0
assert(mz == z)
assert(1/mz < 0 and 0 < 1/z)
@@ -1368,30 +1023,18 @@ test("[test-suite] math: testing -0 and NaN", function (t) {
assert(a1 == a2 and a2 == a4 and a1 ~= a3)
assert(a3 == a5)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: test random for floats", function (t) {
+test("[test-suite] math: test random for floats", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
math.randomseed(0)
@@ -1411,30 +1054,18 @@ test("[test-suite] math: test random for floats", function (t) {
assert(false)
::ok::
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: test random for small intervals", function (t) {
+test("[test-suite] math: test random for small intervals", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local function aux (p, lim) -- test random for small intervals
@@ -1467,30 +1098,18 @@ test("[test-suite] math: test random for small intervals", function (t) {
aux({minint, minint + 9})
aux({maxint - 3, maxint})
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: test random for large intervals", function (t) {
+test("[test-suite] math: test random for large intervals", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local function aux(p1, p2) -- test random for large intervals
@@ -1525,80 +1144,41 @@ test("[test-suite] math: test random for large intervals", function (t) {
end
assert(not pcall(math.random, 1, 2, 3)) -- too many arguments
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: test random for empty interval", function (t) {
+test("[test-suite] math: test random for empty interval", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(not pcall(math.random, minint + 1, minint))
assert(not pcall(math.random, maxint, maxint - 1))
assert(not pcall(math.random, maxint, minint))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] math: interval too large", function (t) {
+test("[test-suite] math: interval too large", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(not pcall(math.random, minint, 0))
assert(not pcall(math.random, -1, maxint))
assert(not pcall(math.random, minint // 2, maxint // 2 + 1))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
diff --git a/tests/test-suite/nextvar.js b/test/test-suite/nextvar.test.js
index 3e05490..1c4f331 100644
--- a/tests/test-suite/nextvar.js
+++ b/test/test-suite/nextvar.test.js
@@ -1,10 +1,8 @@
"use strict";
-const test = require('tape');
-
-const lua = require('../../src/lua.js');
+const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
-const lualib = require('../../src/lualib.js');
+const lualib = require('../../src/lualib.js');
const {to_luastring} = require("../../src/fengaricore.js");
const prefix = `
@@ -14,7 +12,10 @@ const prefix = `
end
`;
-test("[test-suite] nextvar: testing size operator", function (t) {
+test("[test-suite] nextvar: testing size operator", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = {}
@@ -26,30 +27,18 @@ test("[test-suite] nextvar: testing size operator", function (t) {
a[i] = true
assert(#a == i)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] nextvar: testing ipairs", function (t) {
+test("[test-suite] nextvar: testing ipairs", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local x = 0
for k,v in ipairs{10,20,30;x=12} do
@@ -58,30 +47,18 @@ test("[test-suite] nextvar: testing ipairs", function (t) {
end
for _ in ipairs{x=12, y=24} do assert(nil) end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] nextvar: test for 'false' x ipair", function (t) {
+test("[test-suite] nextvar: test for 'false' x ipair", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
x = false
local i = 0
@@ -91,56 +68,32 @@ test("[test-suite] nextvar: test for 'false' x ipair", function (t) {
assert(x == v)
end
assert(i == 4)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] nextvar: iterator function is always the same", function (t) {
+test("[test-suite] nextvar: iterator function is always the same", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(type(ipairs{}) == 'function' and ipairs{} == ipairs{})
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] nextvar: JS tests", { skip: true }, function (t) {
+test.skip("[test-suite] nextvar: JS tests", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
-- testing table sizes
@@ -271,90 +224,54 @@ test("[test-suite] nextvar: JS tests", { skip: true }, function (t) {
end
local a = {}
for i=1,lim do a[i] = true; foo(i, table.unpack(a)) end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] nextvar: test size operation on empty tables", function (t) {
+test("[test-suite] nextvar: test size operation on empty tables", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(#{} == 0)
assert(#{nil} == 0)
assert(#{nil, nil} == 0)
assert(#{nil, nil, nil} == 0)
assert(#{nil, nil, nil, nil} == 0)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] nextvar: test size operation on empty tables", function (t) {
+test("[test-suite] nextvar: test size operation on empty tables", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(#{} == 0)
assert(#{nil} == 0)
assert(#{nil, nil} == 0)
assert(#{nil, nil, nil} == 0)
assert(#{nil, nil, nil, nil} == 0)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] nextvar: next uses always the same iteration function", function (t) {
+test("[test-suite] nextvar: next uses always the same iteration function", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local nofind = {}
@@ -392,83 +309,47 @@ test("[test-suite] nextvar: next uses always the same iteration function", funct
assert(nofind==find("return"))
_G["xxx"] = 1
assert(xxx==find("xxx"))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] nextvar: invalid key to 'next'", function (t) {
+test("[test-suite] nextvar: invalid key to 'next'", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
checkerror("invalid key", next, {10,20}, 3)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] nextvar: both 'pairs' and 'ipairs' need an argument", function (t) {
+test("[test-suite] nextvar: both 'pairs' and 'ipairs' need an argument", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
checkerror("bad argument", pairs)
checkerror("bad argument", ipairs)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] nextvar: fmod table", function (t) {
+test("[test-suite] nextvar: fmod table", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
a = {}
for i=0,10000 do
@@ -484,30 +365,18 @@ test("[test-suite] nextvar: fmod table", function (t) {
end
assert(n.n == 9000)
a = nil
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] nextvar: check next", function (t) {
+test("[test-suite] nextvar: check next", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function checknext (a)
local b = {}
@@ -521,30 +390,18 @@ test("[test-suite] nextvar: check next", function (t) {
checknext{1,2,3,x=1,y=2,z=3}
checknext{1,2,3,4,x=1,y=2,z=3}
checknext{1,2,3,4,5,x=1,y=2,z=3}
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] nextvar: # operator", function (t) {
+test("[test-suite] nextvar: # operator", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(#{} == 0)
assert(#{[-1] = 2} == 0)
@@ -554,30 +411,18 @@ test("[test-suite] nextvar: # operator", function (t) {
for j=1,i do a[j]=j end
assert(#a == i)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] nextvar: maxn", function (t) {
+test("[test-suite] nextvar: maxn", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
-- 'maxn' is now deprecated, but it is easily defined in Lua
function table.maxn (t)
@@ -595,58 +440,34 @@ test("[test-suite] nextvar: maxn", function (t) {
assert(table.maxn{[10] = true, [100*math.pi] = print} == 100*math.pi)
table.maxn = nil
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] nextvar: int overflow", function (t) {
+test("[test-suite] nextvar: int overflow", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
a = {}
for i=0,50 do a[2^i] = true end
assert(a[#a])
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] nextvar: erasing values", function (t) {
+test("[test-suite] nextvar: erasing values", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local t = {[{1}] = 1, [{2}] = 2, [string.rep("x ", 4)] = 3,
[100.3] = 4, [4] = 5}
@@ -720,30 +541,18 @@ test("[test-suite] nextvar: erasing values", function (t) {
assert(a[#a] == 30)
assert(table.remove(a, 2) == 20)
assert(a[#a] == 30 and #a == 2)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] nextvar: testing table library with metamethods", function (t) {
+test("[test-suite] nextvar: testing table library with metamethods", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local function test (proxy, t)
@@ -790,30 +599,18 @@ test("[test-suite] nextvar: testing table library with metamethods", function (t
assert(table.concat(t, ";") == "2;3;4;5;6")
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] nextvar: JS tests", { skip: true }, function (t) {
+test.skip("[test-suite] nextvar: JS tests", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local tab = {10, 20, 30}
local mt = {}
@@ -843,30 +640,18 @@ test("[test-suite] nextvar: JS tests", { skip: true }, function (t) {
debug.setmetatable(u2, {__newindex = function (_, k, v) tab2[k] = v end})
table.move(u, 1, 4, 1, u2)
assert(#tab2 == 4 and tab2[1] == tab[1] and tab2[4] == tab[4])
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] nextvar: next", function (t) {
+test("[test-suite] nextvar: next", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
a = {}
for i=1,1000 do
@@ -882,30 +667,18 @@ test("[test-suite] nextvar: next", function (t) {
for i=0,1,-1 do error'not here' end
a = nil; for i=1,1 do assert(not a); a=1 end; assert(a)
a = nil; for i=1,1,-1 do assert(not a); a=1 end; assert(a)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] nextvar: testing floats in numeric for", function (t) {
+test("[test-suite] nextvar: testing floats in numeric for", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local a
@@ -925,56 +698,32 @@ test("[test-suite] nextvar: testing floats in numeric for", function (t) {
a = 0; for i=99999, 1e5, -1.0 do a=a+1 end; assert(a==0)
a = 0; for i=1.0, 0.99999, -1 do a=a+1 end; assert(a==1)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] nextvar: conversion", function (t) {
+test("[test-suite] nextvar: conversion", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
a = 0; for i="10","1","-2" do a=a+1 end; assert(a==5)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] nextvar: checking types", function (t) {
+test("[test-suite] nextvar: checking types", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local c
@@ -1029,30 +778,18 @@ test("[test-suite] nextvar: checking types", function (t) {
for i = math.maxinteger, 10e100, -1 do assert(false) end
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] nextvar: testing generic 'for'", function (t) {
+test("[test-suite] nextvar: testing generic 'for'", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function f (n, p)
local t = {}; for i=1,p do t[i] = i*10 end
@@ -1070,30 +807,18 @@ test("[test-suite] nextvar: testing generic 'for'", function (t) {
assert(a == 10 and b == 20 and c == 30 and d == nil)
end
assert(x == 5)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] nextvar: testing __pairs and __ipairs metamethod", function (t) {
+test("[test-suite] nextvar: testing __pairs and __ipairs metamethod", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
a = {}
do
@@ -1122,30 +847,18 @@ test("[test-suite] nextvar: testing __pairs and __ipairs metamethod", function (
a.n = 5
a[3] = 30
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] nextvar: testing ipairs with metamethods", function (t) {
+test("[test-suite] nextvar: testing ipairs with metamethods", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
a = {n=10}
setmetatable(a, { __index = function (t,k)
@@ -1157,24 +870,9 @@ test("[test-suite] nextvar: testing ipairs with metamethods", function (t) {
assert(k == i and v == i * 10)
end
assert(i == a.n)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
diff --git a/tests/test-suite/pm-classes.lua b/test/test-suite/pm-classes.lua
index 59cca12..59cca12 100644
--- a/tests/test-suite/pm-classes.lua
+++ b/test/test-suite/pm-classes.lua
diff --git a/tests/test-suite/pm-gsub.lua b/test/test-suite/pm-gsub.lua
index d873cce..d873cce 100644
--- a/tests/test-suite/pm-gsub.lua
+++ b/test/test-suite/pm-gsub.lua
diff --git a/tests/test-suite/pm.js b/test/test-suite/pm.test.js
index 214d498..c2d0de5 100644
--- a/tests/test-suite/pm.js
+++ b/test/test-suite/pm.test.js
@@ -1,13 +1,14 @@
"use strict";
-const test = require('tape');
-
-const lua = require('../../src/lua.js');
+const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
-const lualib = require('../../src/lualib.js');
+const lualib = require('../../src/lualib.js');
const {to_luastring} = require("../../src/fengaricore.js");
-test("[test-suite] pm: pattern matching", function (t) {
+test("[test-suite] pm: pattern matching", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
function f(s, p)
local i,e = string.find(s, p)
@@ -85,30 +86,18 @@ test("[test-suite] pm: pattern matching", function (t) {
-- assert(f(']]]áb', '[^]]') == 'á')
assert(f("0alo alo", "%x*") == "0a")
assert(f("alo alo", "%C+") == "alo alo")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] pm: tonumber", function (t) {
+test("[test-suite] pm: tonumber", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
function f1(s, p)
p = string.gsub(p, "%%([0-9])", function (s)
@@ -124,30 +113,18 @@ test("[test-suite] pm: tonumber", function (t) {
-- assert(f1('axz123= 4= 4 34', '(.+)=(.*)=%2 %1') == '3= 4= 4 3')
-- assert(f1('=======', '^(=*)=%1$') == '=======')
assert(string.match('==========', '^([=]*)=%1$') == nil)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] pm: range", function (t) {
+test("[test-suite] pm: range", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function range (i, j)
if i <= j then
@@ -176,78 +153,42 @@ test("[test-suite] pm: range", function (t) {
assert(strset('[%^%[%-a%]%-b]') == '-[]^ab')
assert(strset('%Z') == strset('[\\1-\\255]'))
assert(strset('.') == strset('[\\1-\\255%z]'))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-// Can't be represented by JS string, testing from actual lua file
-test("[test-suite] pm: classes", function (t) {
- let L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadfile(L, to_luastring("tests/test-suite/pm-classes.lua"));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
-});
// Can't be represented by JS string, testing from actual lua file
-test("[test-suite] pm: gsub", function (t) {
- let L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadfile(L, to_luastring("tests/test-suite/pm-gsub.lua"));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
+test("[test-suite] pm: classes", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadfile(L, to_luastring("test/test-suite/pm-classes.lua")) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
+});
- }, "Lua program ran without error");
+// Can't be represented by JS string, testing from actual lua file
+test("[test-suite] pm: gsub", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadfile(L, to_luastring("test/test-suite/pm-gsub.lua")) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] pm: empty matches", function (t) {
+test("[test-suite] pm: empty matches", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do -- new (5.3.3) semantics for empty matches
assert(string.gsub("a b cd", " *", "-") == "-a-b-c-d-")
@@ -261,30 +202,18 @@ test("[test-suite] pm: empty matches", function (t) {
end
assert(res == "-a-b-c-d-")
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] pm: gsub", function (t) {
+test("[test-suite] pm: gsub", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(string.gsub("um (dois) tres (quatro)", "(%(%w+%))", string.upper) ==
"um (DOIS) tres (QUATRO)")
@@ -315,30 +244,18 @@ test("[test-suite] pm: gsub", function (t) {
t[a] = b-a;
end)
assert(s == r and t[1] == 1 and t[3] == 3 and t[7] == 4 and t[13] == 4)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] pm: gsub isbalanced", function (t) {
+test("[test-suite] pm: gsub isbalanced", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
function isbalanced (s)
return string.find(string.gsub(s, "%b()", ""), "[()]") == nil
@@ -347,30 +264,18 @@ test("[test-suite] pm: gsub isbalanced", function (t) {
assert(isbalanced("(9 ((8))(\\0) 7) \\0\\0 a b ()(c)() a"))
assert(not isbalanced("(9 ((8) 7) a b (\\0 c) a"))
assert(string.gsub("alo 'oi' alo", "%b''", '"') == 'alo " alo')
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] pm: capture", function (t) {
+test("[test-suite] pm: capture", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function checkerror (msg, f, ...)
local s, err = pcall(f, ...)
@@ -396,30 +301,18 @@ test("[test-suite] pm: capture", function (t) {
checkerror("invalid capture index %%0", string.gsub, "alo", "(%0)", "a")
checkerror("invalid capture index %%1", string.gsub, "alo", "(%1)", "a")
checkerror("invalid use of '%%'", string.gsub, "alo", ".", "%x")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] pm: bug since 2.5 (C-stack overflow) (TODO: _soft)", function (t) {
+test("[test-suite] pm: bug since 2.5 (C-stack overflow) (TODO: _soft)", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
_soft = true
if not _soft then -- TODO
@@ -433,30 +326,18 @@ test("[test-suite] pm: bug since 2.5 (C-stack overflow) (TODO: _soft)", function
r, m = f(200000)
assert(not r and string.find(m, "too complex"))
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] pm: big strings (TODO: _soft)", function (t) {
+test("[test-suite] pm: big strings (TODO: _soft)", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
_soft = true -- TODO
if not _soft then
@@ -470,30 +351,18 @@ test("[test-suite] pm: big strings (TODO: _soft)", function (t) {
a = string.rep('a', 10000) .. string.rep('b', 10000)
assert(not pcall(string.gsub, a, 'b'))
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] pm: recursive nest of gsubs", function (t) {
+test("[test-suite] pm: recursive nest of gsubs", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
function rev (s)
return string.gsub(s, "(.)(.+)", function (c,s1) return rev(s1)..c end)
@@ -501,30 +370,18 @@ test("[test-suite] pm: recursive nest of gsubs", function (t) {
local x = "abcdef"
assert(rev(rev(x)) == x)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] pm: gsub with tables", function (t) {
+test("[test-suite] pm: gsub with tables", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(string.gsub("alo alo", ".", {}) == "alo alo")
assert(string.gsub("alo alo", "(.)", {a="AA", l=""}) == "AAo AAo")
@@ -535,30 +392,18 @@ test("[test-suite] pm: gsub with tables", function (t) {
t = {}; setmetatable(t, {__index = function (t,s) return string.upper(s) end})
assert(string.gsub("a alo b hi", "%w%w+", t) == "a ALO b HI")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] pm: gmatch", function (t) {
+test("[test-suite] pm: gmatch", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = 0
for i in string.gmatch('abcde', '()') do assert(i == a+1); a=i end
@@ -583,30 +428,18 @@ test("[test-suite] pm: gmatch", function (t) {
a = 0
for k,v in pairs(t) do assert(k+1 == v+0); a=a+1 end
assert(a == 3)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] pm: tests for '%f' ('frontiers')", function (t) {
+test("[test-suite] pm: tests for '%f' ('frontiers')", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(string.gsub("aaa aa a aaa a", "%f[%w]a", "x") == "xaa xa x xaa x")
assert(string.gsub("[[]] [][] [[[[", "%f[[].", "x") == "x[]] x]x] x[[[")
@@ -633,30 +466,18 @@ test("[test-suite] pm: tests for '%f' ('frontiers')", function (t) {
assert(table.remove(a, 1) == k)
end
assert(#a == 0)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] pm: malformed patterns", function (t) {
+test("[test-suite] pm: malformed patterns", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function malform (p, m)
m = m or "malformed"
@@ -675,30 +496,18 @@ test("[test-suite] pm: malformed patterns", function (t) {
malform("%ba")
malform("%")
malform("%f", "missing")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] pm: \\0 in patterns", function (t) {
+test("[test-suite] pm: \\0 in patterns", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(string.match("ab\\0\\1\\2c", "[\\0-\\2]+") == "\\0\\1\\2")
assert(string.match("ab\\0\\1\\2c", "[\\0-\\0]+") == "\\0")
@@ -707,51 +516,24 @@ test("[test-suite] pm: \\0 in patterns", function (t) {
assert(string.match("abc\\0efg\\0\\1e\\1g", "%b\\0\\1") == "\\0efg\\0\\1e\\1")
assert(string.match("abc\\0\\0\\0", "%\\0+") == "\\0\\0\\0")
assert(string.match("abc\\0\\0\\0", "%\\0%\\0?") == "\\0\\0")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] pm: magic char after \\0", function (t) {
+test("[test-suite] pm: magic char after \\0", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(string.find("abc\\0\\0","\\0.") == 4)
assert(string.find("abcx\\0\\0abc\\0abc","x\\0\\0abc\\0a.") == 4)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
diff --git a/tests/test-suite/sort.js b/test/test-suite/sort.test.js
index c52f30c..cc33c0c 100644
--- a/tests/test-suite/sort.js
+++ b/test/test-suite/sort.test.js
@@ -1,10 +1,8 @@
"use strict";
-const test = require('tape');
-
-const lua = require('../../src/lua.js');
+const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
-const lualib = require('../../src/lualib.js');
+const lualib = require('../../src/lualib.js');
const {to_luastring} = require("../../src/fengaricore.js");
const prefix = `
@@ -24,7 +22,7 @@ const prefix = `
table.sort(a, func)
x = (os.clock() - x) * 1000
pre = pre or ""
- print(string.format("%ssorting %d %s elements in %.2f msec.", pre, n, msg, x))
+ -- print(string.format("%ssorting %d %s elements in %.2f msec.", pre, n, msg, x))
check(a, func)
end
@@ -32,7 +30,10 @@ const prefix = `
if _soft then limit = 5000 end
`;
-test("[test-suite] sort: testing unpack", function (t) {
+test("[test-suite] sort: testing unpack", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
checkerror("wrong number of arguments", table.insert, {}, 2, 3, 4)
@@ -58,30 +59,18 @@ test("[test-suite] sort: testing unpack", function (t) {
assert(a==1 and x==nil)
a,x = unpack({1,2}, 1, 1)
assert(a==1 and x==nil)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] sort: testing unpack", function (t) {
+test("[test-suite] sort: testing unpack", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local maxi = (1 << 31) - 1 -- maximum value for an int (usually)
@@ -110,60 +99,36 @@ test("[test-suite] sort: testing unpack", function (t) {
a, b = unpack(t, minI, minI); assert(a == 12.3 and b == nil)
a, b = unpack(t, minI + 1, minI); assert(a == nil and b == nil)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] sort: testing unpack", function (t) {
+test("[test-suite] sort: testing unpack", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do -- length is not an integer
local t = setmetatable({}, {__len = function () return 'abc' end})
assert(#t == 'abc')
checkerror("object length is not an integer", table.insert, t, 1)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] sort: testing pack", function (t) {
+test("[test-suite] sort: testing pack", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
a = table.pack()
assert(a[1] == nil and a.n == 0)
@@ -173,30 +138,18 @@ test("[test-suite] sort: testing pack", function (t) {
a = table.pack(nil, nil, nil, nil)
assert(a[1] == nil and a.n == 4)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] sort: testing move", function (t) {
+test("[test-suite] sort: testing move", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
@@ -268,30 +221,18 @@ test("[test-suite] sort: testing move", function (t) {
local stat, msg = pcall(table.move, b, 10, 13, 3, b)
assert(not stat and msg == b)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] sort: testing long move", function (t) {
+test("[test-suite] sort: testing long move", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
-- for very long moves, just check initial accesses and interrupt
@@ -319,60 +260,36 @@ test("[test-suite] sort: testing long move", function (t) {
checkerror("wrap around", table.move, {}, 1, maxI, 2)
checkerror("wrap around", table.move, {}, 1, 2, maxI)
checkerror("wrap around", table.move, {}, minI, -2, 2)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] sort: testing sort, strange lengths", function (t) {
+test("[test-suite] sort: testing sort, strange lengths", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local a = setmetatable({}, {__len = function () return -1 end})
assert(#a == -1)
table.sort(a, error) -- should not compare anything
a = setmetatable({}, {__len = function () return maxI end})
checkerror("too big", table.sort, a)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] sort: test checks for invalid order functions", function (t) {
+test("[test-suite] sort: test checks for invalid order functions", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function check (t)
local function f(a, b) assert(a and b); return true end
@@ -382,30 +299,18 @@ test("[test-suite] sort: test checks for invalid order functions", function (t)
check{1,2,3,4}
check{1,2,3,4,5}
check{1,2,3,4,5,6}
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] sort: sort alpha", function (t) {
+test("[test-suite] sort: sort alpha", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
function check (a, f)
f = f or function (x,y) return x<y end;
@@ -419,30 +324,18 @@ test("[test-suite] sort: sort alpha", function (t) {
table.sort(a)
check(a)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] sort: sort perm", function (t) {
+test("[test-suite] sort: sort perm", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
function check (a, f)
f = f or function (x,y) return x<y end;
@@ -476,30 +369,18 @@ test("[test-suite] sort: sort perm", function (t) {
perm{1,2,3,3,5}
perm{1,2,3,4,5,6}
perm{2,2,3,3,5,6}
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] sort: Invert-sorting", function (t) {
+test("[test-suite] sort: Invert-sorting", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
function check (a, f)
f = f or function (x,y) return x<y end;
@@ -516,8 +397,8 @@ test("[test-suite] sort: Invert-sorting", function (t) {
x = os.clock(); i=0
table.sort(a, function(x,y) i=i+1; return y<x end)
x = (os.clock() - x) * 1000
- print(string.format("Invert-sorting other %d elements in %.2f msec., with %i comparisons",
- limit, x, i))
+ -- print(string.format("Invert-sorting other %d elements in %.2f msec., with %i comparisons",
+ -- limit, x, i))
check(a, function(x,y) return y<x end)
table.sort{} -- empty array
@@ -526,30 +407,18 @@ test("[test-suite] sort: Invert-sorting", function (t) {
timesort(a, limit, function(x,y) return nil end, "equal")
for i,v in pairs(a) do assert(v == false) end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] sort: sorting", function (t) {
+test("[test-suite] sort: sorting", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
function check (a, f)
f = f or function (x,y) return x<y end;
@@ -575,24 +444,9 @@ test("[test-suite] sort: sorting", function (t) {
table.sort(a)
check(a, tt.__lt)
check(a)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
diff --git a/tests/test-suite/strings.js b/test/test-suite/strings.test.js
index cbffe5c..0e37674 100644
--- a/tests/test-suite/strings.js
+++ b/test/test-suite/strings.test.js
@@ -1,10 +1,8 @@
"use strict";
-const test = require('tape');
-
-const lua = require('../../src/lua.js');
+const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
-const lualib = require('../../src/lualib.js');
+const lualib = require('../../src/lualib.js');
const {to_luastring} = require("../../src/fengaricore.js");
const checkerror = `
@@ -16,7 +14,10 @@ const checkerror = `
end
`;
-test('[test-suite] strings: string comparisons', function (t) {
+test('[test-suite] strings: string comparisons', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert('alo' < 'alo1')
assert('' < 'a')
@@ -35,30 +36,18 @@ test('[test-suite] strings: string comparisons', function (t) {
assert('\\0\\0\\0' <= '\\0\\0\\0')
assert('\\0\\0\\0' >= '\\0\\0\\0')
assert(not ('\\0\\0b' < '\\0\\0a\\0'))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test('[test-suite] strings: string.sub', function (t) {
+test('[test-suite] strings: string.sub', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert('alo' < 'alo1')
assert('' < 'a')
@@ -77,30 +66,18 @@ test('[test-suite] strings: string.sub', function (t) {
assert('\\0\\0\\0' <= '\\0\\0\\0')
assert('\\0\\0\\0' >= '\\0\\0\\0')
assert(not ('\\0\\0b' < '\\0\\0a\\0'))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test('[test-suite] strings: string.find', function (t) {
+test('[test-suite] strings: string.find', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(string.find("123456789", "345") == 3)
a,b = string.find("123456789", "345")
@@ -115,30 +92,18 @@ test('[test-suite] strings: string.find', function (t) {
assert(not string.find("", "", 2))
assert(string.find('', 'aaa', 1) == nil)
assert(('alo(.)alo'):find('(.)', 1, 1) == 4)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test('[test-suite] strings: string.len and #', function (t) {
+test('[test-suite] strings: string.len and #', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(string.len("") == 0)
assert(string.len("\\0\\0\\0") == 3)
@@ -147,30 +112,18 @@ test('[test-suite] strings: string.len and #', function (t) {
assert(#"" == 0)
assert(#"\\0\\0\\0" == 3)
assert(#"1234567890" == 10)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test('[test-suite] strings: string.byte/string.char', function (t) {
+test('[test-suite] strings: string.byte/string.char', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(string.byte("a") == 97)
assert(string.byte("\\xe4") > 127)
@@ -204,30 +157,18 @@ test('[test-suite] strings: string.byte/string.char', function (t) {
checkerror("too large", string.rep, 'aa', (1 << 30))
checkerror("too large", string.rep, 'a', (1 << 30), ',')
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test('[test-suite] strings: repetitions with separator', function (t) {
+test('[test-suite] strings: repetitions with separator', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(string.rep('teste', 0, 'xuxu') == '')
assert(string.rep('teste', 1, 'xuxu') == 'teste')
@@ -241,30 +182,18 @@ test('[test-suite] strings: repetitions with separator', function (t) {
assert(string.reverse"\\0001234" == "4321\\0")
for i=0,30 do assert(string.len(string.rep('a', i)) == i) end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test('[test-suite] strings: tostring', function (t) {
+test('[test-suite] strings: tostring', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(type(tostring(nil)) == 'string')
assert(type(tostring(12)) == 'string')
@@ -293,30 +222,18 @@ test('[test-suite] strings: tostring', function (t) {
assert('' .. 12 == '12' and 12.0 .. '' == '12')
assert(tostring(-1203 + 0.0) == "-1203")
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test('[test-suite] strings: string.format', function (t) {
+test('[test-suite] strings: string.format', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
x = '"ílo"\\n\\\\'
assert(string.format('%q%s', x, x) == '"\\\\"ílo\\\\"\\\\\\n\\\\\\\\""ílo"\\n\\\\')
@@ -340,30 +257,18 @@ test('[test-suite] strings: string.format', function (t) {
"-"..string.rep("%", 20)..".20s")
assert(string.format('"-%20s.20s"', string.rep("%", 2000)) ==
string.format("%q", "-"..string.rep("%", 2000)..".20s"))
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test('[test-suite] strings: %q', function (t) {
+test('[test-suite] strings: %q', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local function checkQ (v)
@@ -381,57 +286,33 @@ test('[test-suite] strings: %q', function (t) {
checkQ(false)
checkerror("no literal", string.format, "%q", {})
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test('[test-suite] strings: embedded zeros error', function (t) {
+test('[test-suite] strings: embedded zeros error', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
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 () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test('[test-suite] strings: format x tostring', function (t) {
+test('[test-suite] strings: format x tostring', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(string.format("%s %s", nil, true) == "nil true")
assert(string.format("%s %.4s", false, true) == "false true")
@@ -451,30 +332,18 @@ test('[test-suite] strings: format x tostring', function (t) {
-- assert(string.format("%08X", 0xFFFFFFFF) == "FFFFFFFF")
assert(string.format("%+08d", 31501) == "+0031501")
assert(string.format("%+08d", -30927) == "-0030927")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test('[test-suite] strings: longest number that can be formatted', function (t) {
+test('[test-suite] strings: longest number that can be formatted', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local i = 1
@@ -488,30 +357,18 @@ test('[test-suite] strings: longest number that can be formatted', function (t)
-- assert(string.len(s) >= i + 101)
assert(tonumber(s) == -(10^i))
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test('[test-suite] strings: large numbers for format', function (t) {
+test('[test-suite] strings: large numbers for format', () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do -- assume at least 32 bits
local max, min = 0x7fffffff, -0x80000000 -- "large" for 32 bits
@@ -537,30 +394,18 @@ test('[test-suite] strings: large numbers for format', function (t) {
assert(tostring(1234567890123) == '1234567890123')
end
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] strings: 'format %a %A'", function (t) {
+test("[test-suite] strings: 'format %a %A'", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local function matchhexa (n)
@@ -588,36 +433,24 @@ test("[test-suite] strings: 'format %a %A'", function (t) {
end
if not pcall(string.format, "%.3a", 0) then
- (Message or print)("\\n >>> modifiers for format '%a' not available <<<\\n")
+ -- (Message or print)("\\n >>> modifiers for format '%a' not available <<<\\n")
else
assert(string.find(string.format("%+.2A", 12), "^%+0X%x%.%x0P%+?%d$"))
assert(string.find(string.format("%.4A", -12), "^%-0X%x%.%x000P%+?%d$"))
end
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] strings: errors in format", function (t) {
+test("[test-suite] strings: errors in format", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
local function check (fmt, msg)
checkerror(msg, string.format, fmt, 10)
@@ -634,30 +467,18 @@ 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 () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] strings: table.concat", function (t) {
+test("[test-suite] strings: table.concat", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
checkerror("table expected", table.concat, 3)
assert(table.concat{} == "")
@@ -685,31 +506,19 @@ test("[test-suite] strings: table.concat", function (t) {
assert(table.concat(a, ",", 2) == "b,c")
assert(table.concat(a, ",", 3) == "c")
assert(table.concat(a, ",", 4) == "")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
// TODO: os.setlocale NYI
-test.skip("[test-suite] strings: locale", function (t) {
+test.skip("[test-suite] strings: locale", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
if not _port then
@@ -741,30 +550,18 @@ test.skip("[test-suite] strings: locale", function (t) {
assert(os.setlocale(nil, "numeric") == 'C')
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] strings: bug in Lua 5.3.2: 'gmatch' iterator does not work across coroutines", function (t) {
+test("[test-suite] strings: bug in Lua 5.3.2: 'gmatch' iterator does not work across coroutines", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local f = string.gmatch("1 2 3 4 5", "%d+")
@@ -772,24 +569,9 @@ test("[test-suite] strings: bug in Lua 5.3.2: 'gmatch' iterator does not work ac
co = coroutine.wrap(f)
assert(co() == "2")
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(checkerror + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
diff --git a/tests/test-suite/tpack.js b/test/test-suite/tpack.test.js
index 745c151..3b97d3a 100644
--- a/tests/test-suite/tpack.js
+++ b/test/test-suite/tpack.test.js
@@ -1,10 +1,8 @@
"use strict";
-const test = require('tape');
-
-const lua = require('../../src/lua.js');
+const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
-const lualib = require('../../src/lualib.js');
+const lualib = require('../../src/lualib.js');
const {to_luastring} = require("../../src/fengaricore.js");
const prefix = `
@@ -32,43 +30,34 @@ const prefix = `
local align = packsize("!xXi16")
`;
-test("[test-suite] tpack: maximum size for integers", function (t) {
+test("[test-suite] tpack: maximum size for integers", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(1 <= sizeshort and sizeshort <= sizeint and sizeint <= sizelong and
sizefloat <= sizedouble)
- print("platform:")
- print(string.format(
- "\\tshort %d, int %d, long %d, size_t %d, float %d, double %d,\\n\\z
- \\tlua Integer %d, lua Number %d",
- sizeshort, sizeint, sizelong, sizesize_t, sizefloat, sizedouble,
- sizeLI, sizenumber))
- print("\\t" .. (little and "little" or "big") .. " endian")
- print("\\talignment: " .. align)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ -- print("platform:")
+ -- print(string.format(
+ -- "\\tshort %d, int %d, long %d, size_t %d, float %d, double %d,\\n\\z
+ -- \\tlua Integer %d, lua Number %d",
+ -- sizeshort, sizeint, sizelong, sizesize_t, sizefloat, sizedouble,
+ -- sizeLI, sizenumber))
+ -- print("\\t" .. (little and "little" or "big") .. " endian")
+ -- print("\\talignment: " .. align)
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] tpack: minimum behavior for integer formats", function (t) {
+test("[test-suite] tpack: minimum behavior for integer formats", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(unpack("B", pack("B", 0xff)) == 0xff)
assert(unpack("b", pack("b", 0x7f)) == 0x7f)
@@ -81,30 +70,18 @@ test("[test-suite] tpack: minimum behavior for integer formats", function (t) {
assert(unpack("L", pack("L", 0xffffffff)) == 0xffffffff)
assert(unpack("l", pack("l", 0x7fffffff)) == 0x7fffffff)
assert(unpack("l", pack("l", -0x80000000)) == -0x80000000)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] tpack: minimum behavior for integer formats", function (t) {
+test("[test-suite] tpack: minimum behavior for integer formats", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
for i = 1, NB do
-- small numbers with signal extension ("\\xFF...")
@@ -120,30 +97,18 @@ test("[test-suite] tpack: minimum behavior for integer formats", function (t) {
assert(pack(">I" .. i, 0xAA) == s:reverse())
assert(unpack(">I" .. i, s:reverse()) == 0xAA)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] tpack: minimum behavior for integer formats", function (t) {
+test("[test-suite] tpack: minimum behavior for integer formats", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local lnum = 0x13121110090807060504030201
@@ -165,30 +130,18 @@ test("[test-suite] tpack: minimum behavior for integer formats", function (t) {
checkerror("does not fit", unpack, ">i" .. i, "\\1" .. ("\\x00"):rep(i - 1))
end
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] tpack: minimum behavior for integer formats", function (t) {
+test("[test-suite] tpack: minimum behavior for integer formats", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
for i = 1, sizeLI do
local lstr = "\\1\\2\\3\\4\\5\\6\\7\\8\\9\\10\\11\\12\\13"
@@ -199,30 +152,18 @@ test("[test-suite] tpack: minimum behavior for integer formats", function (t) {
assert(pack(">i" .. i, n) == s:reverse())
assert(unpack(">i" .. i, s:reverse()) == n)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] tpack: sign extension", function (t) {
+test("[test-suite] tpack: sign extension", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local u = 0xf0
@@ -232,30 +173,18 @@ test("[test-suite] tpack: sign extension", function (t) {
u = u * 256 + 0xff
end
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] tpack: mixed endianness", function (t) {
+test("[test-suite] tpack: mixed endianness", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
assert(pack(">i2 <i2", 10, 20) == "\\0\\10\\20\\0")
@@ -263,30 +192,18 @@ test("[test-suite] tpack: mixed endianness", function (t) {
assert(a == 10 and b == 20)
assert(pack("=i4", 2001) == pack("i4", 2001))
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] tpack: testing invalid formats", function (t) {
+test("[test-suite] tpack: testing invalid formats", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
checkerror("out of limits", pack, "i0", 0)
checkerror("out of limits", pack, "i" .. NB + 1, 0)
@@ -298,30 +215,18 @@ test("[test-suite] tpack: testing invalid formats", function (t) {
checkerror("missing size", pack, "c", "")
checkerror("variable%-length format", packsize, "s")
checkerror("variable%-length format", packsize, "z")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] tpack: overflow in option size (error will be in digit after limit)", function (t) {
+test("[test-suite] tpack: overflow in option size (error will be in digit after limit)", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
checkerror("invalid format", packsize, "c1" .. string.rep("0", 40))
@@ -333,30 +238,18 @@ test("[test-suite] tpack: overflow in option size (error will be in digit after
s = string.rep("c268435456", 2^3 - 1) .. "c268435455"
assert(packsize(s) == 0x7fffffff)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] tpack: overflow in packing", function (t) {
+test("[test-suite] tpack: overflow in packing", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
for i = 1, sizeLI - 1 do
local umax = (1 << (i * 8)) - 1
@@ -374,30 +267,18 @@ test("[test-suite] tpack: overflow in packing", function (t) {
assert(unpack("<i" .. i, pack("<i" .. i, min)) == min)
assert(unpack(">I" .. i, pack(">I" .. i, umax)) == umax)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] tpack: Lua integer size", function (t) {
+test("[test-suite] tpack: Lua integer size", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
assert(unpack(">j", pack(">j", math.maxinteger)) == math.maxinteger)
assert(unpack("<j", pack("<j", math.mininteger)) == math.mininteger)
@@ -408,30 +289,18 @@ test("[test-suite] tpack: Lua integer size", function (t) {
else
assert(pack("f", 24) == pack(">f", 24))
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] tpack: testing pack/unpack of floating-point numbers", function (t) {
+test("[test-suite] tpack: testing pack/unpack of floating-point numbers", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
for _, n in ipairs{0, -1.1, 1.9, 1/0, -1/0, 1e20, -1e20, 0.1, 2000.7} do
assert(unpack("n", pack("n", n)) == n)
@@ -448,30 +317,18 @@ test("[test-suite] tpack: testing pack/unpack of floating-point numbers", functi
assert(unpack("<d", pack("<d", n)) == n)
assert(unpack(">d", pack(">d", n)) == n)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] tpack: testing pack/unpack of strings", function (t) {
+test("[test-suite] tpack: testing pack/unpack of strings", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local s = string.rep("abc", 1000)
@@ -514,30 +371,18 @@ test("[test-suite] tpack: testing pack/unpack of strings", function (t) {
assert(a == "abcdefghi" and b == "xyz" and c == 14)
checkerror("longer than", pack, "c3", "1234")
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] tpack: testing multiple types and sequence", function (t) {
+test("[test-suite] tpack: testing multiple types and sequence", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local x = pack("<b h b f d f n i", 1, 2, 3, 4, 5, 6, 7, 8)
@@ -546,30 +391,18 @@ test("[test-suite] tpack: testing multiple types and sequence", function (t) {
assert(a == 1 and b == 2 and c == 3 and d == 4 and e == 5 and f == 6 and
g == 7 and h == 8)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] tpack: testing alignment", function (t) {
+test("[test-suite] tpack: testing alignment", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
assert(pack(" < i1 i2 ", 2, 3) == "\\2\\3\\0") -- no alignment by default
@@ -612,30 +445,18 @@ test("[test-suite] tpack: testing alignment", function (t) {
checkerror("invalid next option", unpack, "X i", "")
checkerror("invalid next option", pack, "Xc1")
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] tpack: testing initial position", function (t) {
+test("[test-suite] tpack: testing initial position", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
do
local x = pack("i4i4i4i4", 1, 2, 3, 4)
@@ -667,24 +488,9 @@ test("[test-suite] tpack: testing initial position", function (t) {
checkerror("out of string", unpack, "c0", x, -(#x + 1))
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(prefix + luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
diff --git a/tests/test-suite/utf8.js b/test/test-suite/utf8.test.js
index 173dffd..7e809da 100644
--- a/tests/test-suite/utf8.js
+++ b/test/test-suite/utf8.test.js
@@ -1,10 +1,8 @@
"use strict";
-const test = require('tape');
-
-const lua = require('../../src/lua.js');
+const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
-const lualib = require('../../src/lualib.js');
+const lualib = require('../../src/lualib.js');
const {to_luastring} = require("../../src/fengaricore.js");
const prefix = `
@@ -96,28 +94,25 @@ const prefix = `
end
`;
-test("[test-suite] utf8: offset", function (t) {
+test("[test-suite] utf8: offset", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = prefix + `
assert(utf8.offset("alo", 5) == nil)
assert(utf8.offset("alo", -4) == nil)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
- lualib.luaL_openlibs(L);
- if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
- throw new SyntaxError(lua.lua_tojsstring(L, -1));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] utf8: error indication in utf8.len", function (t) {
+test("[test-suite] utf8: error indication in utf8.len", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = prefix + `
do
local function check (s, p)
@@ -129,24 +124,18 @@ test("[test-suite] utf8: error indication in utf8.len", function (t) {
check("\\xF4\\x9F\\xBF", 1)
check("\\xF4\\x9F\\xBF\\xBF", 1)
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
- lualib.luaL_openlibs(L);
- if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
- throw new SyntaxError(lua.lua_tojsstring(L, -1));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] utf8: error in initial position for offset", function (t) {
+test("[test-suite] utf8: error in initial position for offset", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = prefix + `
checkerror("position out of range", utf8.offset, "abc", 1, 5)
checkerror("position out of range", utf8.offset, "abc", 1, -4)
@@ -155,24 +144,18 @@ test("[test-suite] utf8: error in initial position for offset", function (t) {
checkerror("continuation byte", utf8.offset, "𦧺", 1, 2)
checkerror("continuation byte", utf8.offset, "𦧺", 1, 2)
checkerror("continuation byte", utf8.offset, "\\x80", 1)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
- lualib.luaL_openlibs(L);
- if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
- throw new SyntaxError(lua.lua_tojsstring(L, -1));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] utf8: codepoints", function (t) {
+test("[test-suite] utf8: codepoints", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = prefix + `
local s = "hello World"
local t = {string.byte(s, 1, -1)}
@@ -199,110 +182,80 @@ test("[test-suite] utf8: codepoints", function (t) {
assert(utf8.codepoint(utf8.char(0x10FFFF)) == 0x10FFFF)
checkerror("value out of range", utf8.char, 0x10FFFF + 1)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
- lualib.luaL_openlibs(L);
- if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
- throw new SyntaxError(lua.lua_tojsstring(L, -1));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] utf8: UTF-8 representation for 0x11ffff (value out of valid range)", function (t) {
+test("[test-suite] utf8: UTF-8 representation for 0x11ffff (value out of valid range)", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = prefix + `
invalid("\\xF4\\x9F\\xBF\\xBF")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
- lualib.luaL_openlibs(L);
- if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
- throw new SyntaxError(lua.lua_tojsstring(L, -1));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] utf8: overlong sequences", function (t) {
+test("[test-suite] utf8: overlong sequences", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = prefix + `
invalid("\\xC0\\x80") -- zero
invalid("\\xC1\\xBF") -- 0x7F (should be coded in 1 byte)
invalid("\\xE0\\x9F\\xBF") -- 0x7FF (should be coded in 2 bytes)
invalid("\\xF0\\x8F\\xBF\\xBF") -- 0xFFFF (should be coded in 3 bytes)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
- lualib.luaL_openlibs(L);
- if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
- throw new SyntaxError(lua.lua_tojsstring(L, -1));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] utf8: invalid bytes", function (t) {
+test("[test-suite] utf8: invalid bytes", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = prefix + `
invalid("\\x80") -- continuation byte
invalid("\\xBF") -- continuation byte
invalid("\\xFE") -- invalid byte
invalid("\\xFF") -- invalid byte
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
- lualib.luaL_openlibs(L);
- if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
- throw new SyntaxError(lua.lua_tojsstring(L, -1));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] utf8: empty strings", function (t) {
+test("[test-suite] utf8: empty strings", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = prefix + `
check("", {})
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
- lualib.luaL_openlibs(L);
- if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
- throw new SyntaxError(lua.lua_tojsstring(L, -1));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] utf8: minimum and maximum values for each sequence size", function (t) {
+test("[test-suite] utf8: minimum and maximum values for each sequence size", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = prefix + `
s = "\\0 \\x7F\\z
\\xC2\\x80 \\xDF\\xBF\\z
@@ -332,18 +285,9 @@ test("[test-suite] utf8: minimum and maximum values for each sequence size", fun
assert(utf8.offset(x, 0, p + j - 1) == p)
end
end
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
- lualib.luaL_openlibs(L);
- if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
- throw new SyntaxError(lua.lua_tojsstring(L, -1));
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
- }, "Lua program ran without error");
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
diff --git a/tests/test-suite/vararg.js b/test/test-suite/vararg.test.js
index 1cc5ace..0538541 100644
--- a/tests/test-suite/vararg.js
+++ b/test/test-suite/vararg.test.js
@@ -1,13 +1,14 @@
"use strict";
-const test = require('tape');
-
-const lua = require('../../src/lua.js');
+const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
-const lualib = require('../../src/lualib.js');
+const lualib = require('../../src/lualib.js');
const {to_luastring} = require("../../src/fengaricore.js");
-test("[test-suite] vararg: testing vararg", function (t) {
+test("[test-suite] vararg: testing vararg", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
function f(a, ...)
local arg = {n = select('#', ...), ...}
@@ -44,7 +45,7 @@ test("[test-suite] vararg: testing vararg", function (t) {
assert(a[1] == b and a[2] == c and a.n == 2)
a = vararg(call(call, {c12, {1,2}}))
assert(a.n == 2 and a[1] == 55 and a[2] == 2)
- a = call(print, {'+'})
+ a = call(function()end, {'+'})
assert(a == nil)
local t = {1, 10}
@@ -72,30 +73,18 @@ test("[test-suite] vararg: testing vararg", function (t) {
i = 1
while i <= lim do a[i] = i; i=i+1 end
assert(call(math.max, a) == lim)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] vararg: new-style varargs", function (t) {
+test("[test-suite] vararg: new-style varargs", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
function oneless (a, ...) return ... end
@@ -117,30 +106,18 @@ test("[test-suite] vararg: new-style varargs", function (t) {
a,b,c,d,e = f(4)
assert(a==nil and b==nil and c==nil and d==nil and e==nil)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] vararg: varargs for main chunks", function (t) {
+test("[test-suite] vararg: varargs for main chunks", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
f = load[[ return {...} ]]
x = f(2,3)
@@ -167,30 +144,18 @@ test("[test-suite] vararg: varargs for main chunks", function (t) {
assert(a[1] == 5 and a[2] == 7 and a[3] == nil)
pcall(select, 10000)
pcall(select, -10000)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
-test("[test-suite] vararg: bug in 5.2.2", function (t) {
+test("[test-suite] vararg: bug in 5.2.2", () => {
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
let luaCode = `
function f(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
p11, p12, p13, p14, p15, p16, p17, p18, p19, p20,
@@ -203,24 +168,9 @@ test("[test-suite] vararg: bug in 5.2.2", function (t) {
-- assertion fail here
f()
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
+ `;
+ lualib.luaL_openlibs(L);
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) === lua.LUA_ERRSYNTAX)
+ throw new SyntaxError(lua.lua_tojsstring(L, -1));
+ lua.lua_call(L, 0, 0);
});
diff --git a/tests/tests.js b/test/tests.js
index 778cbef..631594b 100644
--- a/tests/tests.js
+++ b/test/tests.js
@@ -5,7 +5,12 @@ const lauxlib = require("../src/lauxlib.js");
const {to_luastring} = require("../src/fengaricore.js");
const toByteCode = function(luaCode) {
- let L = getState(luaCode);
+ let L = lauxlib.luaL_newstate();
+ if (!L) throw Error("failed to create lua state");
+
+ if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) !== lua.LUA_OK)
+ throw Error(lua.lua_tojsstring(L, -1));
+
let b = [];
if (lua.lua_dump(L, function(L, b, size, B) {
B.push(...b.slice(0, size));
@@ -15,16 +20,4 @@ const toByteCode = function(luaCode) {
return Uint8Array.from(b);
};
-const getState = function(luaCode) {
- let L = lauxlib.luaL_newstate();
- if (!L)
- throw Error("unable to create lua_State");
-
- if (lauxlib.luaL_loadstring(L, to_luastring(luaCode)) !== lua.LUA_OK)
- throw Error(lua.lua_tojsstring(L, -1));
-
- return L;
-};
-
-module.exports.getState = getState;
module.exports.toByteCode = toByteCode;
diff --git a/tests/defs.js b/tests/defs.js
deleted file mode 100644
index f24dee0..0000000
--- a/tests/defs.js
+++ /dev/null
@@ -1,89 +0,0 @@
-const test = require('tape');
-
-const defs = require('../src/defs.js');
-
-const unicode_tests = [
- {
- description: "Convert normal ascii string",
- literal: "foo",
- byte_array: defs.luastring_of("f".charCodeAt(0), "o".charCodeAt(0), "o".charCodeAt(0))
- },
- {
- description: "Convert ascii string containing null byte",
- literal: "fo\0o",
- byte_array: defs.luastring_of("f".charCodeAt(0), "o".charCodeAt(0), 0, "o".charCodeAt(0))
- },
- {
- description: "Convert string with BMP unicode chars",
- literal: "Café",
- byte_array: defs.luastring_of(67, 97, 102, 195, 169)
- },
- {
- description: "Convert string with codepoint in PUA (U+E000 to U+F8FF)",
- literal: "",
- byte_array: defs.luastring_of(239, 163, 191)
- },
- {
- description: "Convert string with surrogate pair",
- literal: "❤️🍾",
- byte_array: defs.luastring_of(226, 157, 164, 239, 184, 143, 240, 159, 141, 190)
- },
- {
- description: "Convert string with broken surrogate pair",
- literal: "\uD800a",
- byte_array: defs.luastring_of(237, 160, 128, 97)
- },
- {
- description: "Convert string with broken surrogate pair at end of string",
- literal: "\uD823",
- byte_array: defs.luastring_of(237, 160, 163)
- }
-];
-
-test('to_luastring', function (t) {
- t.plan(unicode_tests.length);
-
- 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);
-
- 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.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([225, 60, 145]);
- }, "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, 145, 60, 145]);
- }, "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
deleted file mode 100644
index 56859d8..0000000
--- a/tests/lapi.js
+++ /dev/null
@@ -1,544 +0,0 @@
-"use strict";
-
-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 {to_luastring} = require("../src/fengaricore.js");
-
-test('luaL_newstate, lua_pushnil, luaL_typename', function (t) {
- let L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lua.lua_pushnil(L);
-
- }, "JS Lua program ran without error");
-
- t.deepEqual(
- lauxlib.luaL_typename(L, -1),
- "nil".split('').map(e => e.charCodeAt(0)),
- "Correct element(s) on the stack"
- );
-});
-
-
-test('lua_pushnumber', function (t) {
- let L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lua.lua_pushnumber(L, 10.5);
-
- }, "JS Lua program ran without error");
-
- t.deepEqual(
- lauxlib.luaL_typename(L, -1),
- "number".split('').map(e => e.charCodeAt(0)),
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tonumber(L, -1),
- 10.5,
- "top is correct"
- );
-});
-
-
-test('lua_pushinteger', function (t) {
- let L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lua.lua_pushinteger(L, 10);
-
- }, "JS Lua program ran without error");
-
- t.deepEqual(
- lauxlib.luaL_typename(L, -1),
- "number".split('').map(e => e.charCodeAt(0)),
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 10,
- "top is correct"
- );
-});
-
-
-test('lua_pushliteral', function (t) {
- let L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lua.lua_pushliteral(L, "hello");
-
- }, "JS Lua program ran without error");
-
- t.deepEqual(
- lauxlib.luaL_typename(L, -1),
- "string".split('').map(e => e.charCodeAt(0)),
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello",
- "top is correct"
- );
-});
-
-
-test('lua_pushboolean', function (t) {
- let L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lua.lua_pushboolean(L, true);
-
- }, "JS Lua program ran without error");
-
- t.deepEqual(
- lauxlib.luaL_typename(L, -1),
- "boolean".split('').map(e => e.charCodeAt(0)),
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_toboolean(L, -1),
- true,
- "top is correct"
- );
-});
-
-
-test('lua_pushvalue', function (t) {
- let L;
-
- t.plan(5);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lua.lua_pushliteral(L, "hello");
-
- lua.lua_pushvalue(L, -1);
-
- }, "JS Lua program ran without error");
-
- t.deepEqual(
- lauxlib.luaL_typename(L, -1),
- "string".split('').map(e => e.charCodeAt(0)),
- "Correct element(s) on the stack"
- );
-
- t.deepEqual(
- lauxlib.luaL_typename(L, -2),
- "string".split('').map(e => e.charCodeAt(0)),
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -2),
- "hello",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('lua_pushjsclosure', function (t) {
- let L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- let fn = function(L) {
- return 0;
- };
-
- L = lauxlib.luaL_newstate();
-
- lua.lua_pushliteral(L, "a value associated to the C closure");
- lua.lua_pushjsclosure(L, fn, 1);
-
- }, "JS Lua program ran without error");
-
- t.deepEqual(
- lauxlib.luaL_typename(L, -1),
- "function".split('').map(e => e.charCodeAt(0)),
- "Correct element(s) on the stack"
- );
-});
-
-
-test('lua_pushjsfunction', function (t) {
- let L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- let fn = function(L) {
- return 0;
- };
-
- L = lauxlib.luaL_newstate();
-
- lua.lua_pushjsfunction(L, fn);
-
- }, "JS Lua program ran without error");
-
- t.deepEqual(
- lauxlib.luaL_typename(L, -1),
- "function".split('').map(e => e.charCodeAt(0)),
- "Correct element(s) on the stack"
- );
-});
-
-
-test('lua_call (calling a light JS function)', function (t) {
- let L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- let fn = function(L) {
- lua.lua_pushliteral(L, "hello");
- return 1;
- };
-
- L = lauxlib.luaL_newstate();
-
- lua.lua_pushjsfunction(L, fn);
-
- lua.lua_call(L, 0, 1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello",
- "top is correct"
- );
-});
-
-
-test('lua_call (calling a JS closure)', function (t) {
- let L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- let fn = function(L) {
- lua.lua_pushstring(L, lua.lua_tostring(L, lua.lua_upvalueindex(1)));
- return 1;
- };
-
- L = lauxlib.luaL_newstate();
-
- lua.lua_pushliteral(L, "upvalue hello !");
- lua.lua_pushjsclosure(L, fn, 1);
-
- lua.lua_call(L, 0, 1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "upvalue hello !",
- "top is correct"
- );
-});
-
-
-test('lua_pcall (calling a light JS function)', function (t) {
- let L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- let fn = function(L) {
- lua.lua_pushliteral(L, "hello");
- return 1;
- };
-
- L = lauxlib.luaL_newstate();
-
- lua.lua_pushjsfunction(L, fn);
-
- lua.lua_pcall(L, 0, 1, 0);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello",
- "top is correct"
- );
-});
-
-
-test('lua_pcall that breaks', function (t) {
- let L;
-
- t.plan(1);
-
- t.doesNotThrow(function () {
-
- let fn = function(L) {
- return "undefined_value";
- };
-
- L = lauxlib.luaL_newstate();
-
- lua.lua_pushjsfunction(L, fn);
-
- lua.lua_pcall(L, 0, 1, 0);
-
- }, "JS Lua program ran without error");
-
- console.log(L.stack[L.top - 1].value);
-});
-
-
-test('lua_pop', function (t) {
- let L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lua.lua_pushliteral(L, "hello");
- lua.lua_pushliteral(L, "world");
-
- lua.lua_pop(L, 1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('lua_load with no chunkname', function (t) {
- let L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
-
- lua.lua_load(L, function(L, s) { let r = s.code; s.code = null; return r; }, {code: to_luastring("return 'hello'")}, null, null);
-
- lua.lua_call(L, 0, 1);
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello",
- "Correct element(s) on the stack"
- );
-});
-
-test('lua_load and lua_call it', function (t) {
- let luaCode = `
- local a = "JS > Lua > JS \\\\o/"
- return a
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- let bc = toByteCode(luaCode);
-
- L = lauxlib.luaL_newstate();
-
- lua.lua_load(L, function(L, s) { let r = s.bc; s.bc = null; return r; }, {bc: bc}, to_luastring("test-lua_load"), to_luastring("binary"));
-
- lua.lua_call(L, 0, 1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "JS > Lua > JS \\o/",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('lua script reads js upvalues', function (t) {
- let luaCode = `
- return js .. " world"
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_pushliteral(L, "hello");
- lua.lua_setglobal(L, to_luastring("js"));
-
- lua.lua_call(L, 0, 1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello world",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('lua_createtable', function (t) {
- let L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
-
- lua.lua_createtable(L, 3, 3);
-
- }, "JS Lua program ran without error");
-
- t.ok(
- lua.lua_istable(L, -1),
- "Correct element(s) on the stack"
- );
-});
-
-
-test('lua_newtable', function (t) {
- let L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
-
- lua.lua_newtable(L);
-
- }, "JS Lua program ran without error");
-
- t.ok(
- lua.lua_istable(L, -1),
- "Correct element(s) on the stack"
- );
-});
-
-
-test('lua_settable, lua_gettable', function (t) {
- let L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
-
- lua.lua_newtable(L);
-
- lua.lua_pushliteral(L, "key");
- lua.lua_pushliteral(L, "value");
-
- lua.lua_settable(L, -3);
-
- lua.lua_pushliteral(L, "key");
- lua.lua_gettable(L, -2);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "value",
- "Correct element(s) on the stack"
- );
-});
-
-test('lua_atnativeerror', function(t) {
- t.plan(7);
-
- let L = lauxlib.luaL_newstate();
- let errob = {};
-
- lua.lua_pushcfunction(L, function(L) {
- throw errob;
- });
- t.strictEqual(lua.lua_pcall(L, 0, 0, 0), -1, "without a native error handler pcall should be -1");
- lua.lua_pop(L, 1);
-
-
- lua.lua_atnativeerror(L, function(L) {
- let e = lua.lua_touserdata(L, 1);
- t.strictEqual(e, errob);
- lua.lua_pushstring(L, to_luastring("runtime error!"));
- return 1;
- });
- lua.lua_pushcfunction(L, function(L) {
- throw errob;
- });
- t.strictEqual(lua.lua_pcall(L, 0, 0, 0), lua.LUA_ERRRUN, "should return lua.LUA_ERRRUN");
- t.strictEqual(lua.lua_tojsstring(L, -1), "runtime error!");
- lua.lua_pop(L, 1);
-
-
- lua.lua_atnativeerror(L, function(L) {
- let e = lua.lua_touserdata(L, 1);
- t.strictEqual(e, errob);
- lauxlib.luaL_error(L, to_luastring("runtime error!"));
- });
- lua.lua_pushcfunction(L, function(L) {
- throw errob;
- });
- t.strictEqual(lua.lua_pcall(L, 0, 0, 0), lua.LUA_ERRRUN, "luaL_error from a native error handler should result in LUA_ERRRUN");
- t.strictEqual(lua.lua_tojsstring(L, -1), "runtime error!");
- lua.lua_pop(L, 1);
-});
diff --git a/tests/lbaselib.js b/tests/lbaselib.js
deleted file mode 100644
index 6bef0d8..0000000
--- a/tests/lbaselib.js
+++ /dev/null
@@ -1,651 +0,0 @@
-"use strict";
-
-const test = require('tape');
-
-const lua = require('../src/lua.js');
-const lauxlib = require('../src/lauxlib.js');
-const lualib = require('../src/lualib.js');
-const {to_luastring} = require("../src/fengaricore.js");
-
-
-test('print', function (t) {
- let luaCode = `
- print("hello", "world", 123)
- `, L;
-
- t.plan(1);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-});
-
-
-test('setmetatable, getmetatable', function (t) {
- let luaCode = `
- local mt = {
- __index = function ()
- print("hello")
- return "hello"
- end
- }
-
- local t = {}
-
- setmetatable(t, mt);
-
- return t[1], getmetatable(t)
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -2),
- "hello",
- "Correct element(s) on the stack"
- );
-
- t.ok(
- lua.lua_istable(L, -1),
- "Correct element(s) on the stack"
- );
-});
-
-
-test('rawequal', function (t) {
- let luaCode = `
- local mt = {
- __eq = function ()
- return true
- end
- }
-
- local t1 = {}
- local t2 = {}
-
- setmetatable(t1, mt);
-
- return rawequal(t1, t2), t1 == t2
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.notOk(
- lua.lua_toboolean(L, -2),
- "Correct element(s) on the stack"
- );
-
- t.ok(
- lua.lua_toboolean(L, -1),
- "Correct element(s) on the stack"
- );
-});
-
-
-test('rawset, rawget', function (t) {
- let luaCode = `
- local mt = {
- __newindex = function (table, key, value)
- rawset(table, key, "hello")
- end
- }
-
- local t = {}
-
- setmetatable(t, mt);
-
- t["yo"] = "bye"
- rawset(t, "yoyo", "bye")
-
- return rawget(t, "yo"), t["yo"], rawget(t, "yoyo"), t["yoyo"]
- `, L;
-
- t.plan(5);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -4),
- "hello",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -3),
- "hello",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -2),
- "bye",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "bye",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('type', function (t) {
- let luaCode = `
- return type(1), type(true), type("hello"), type({}), type(nil)
- `, L;
-
- t.plan(6);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -5),
- "number",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -4),
- "boolean",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -3),
- "string",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -2),
- "table",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "nil",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('error', function (t) {
- let luaCode = `
- error("you fucked up")
- `, L;
-
- t.plan(1);
-
- t.throws(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-});
-
-
-test('error, protected', function (t) {
- let luaCode = `
- error("you fucked up")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_pcall(L, 0, -1, 0);
-
- }, "JS Lua program ran without error");
-
- t.ok(
- lua.lua_tojsstring(L, -1).endsWith("you fucked up"),
- "Error is on the stack"
- );
-});
-
-
-test('pcall', function (t) {
- let luaCode = `
- local willFail = function ()
- error("you fucked up")
- end
-
- return pcall(willFail)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.ok(
- lua.lua_tojsstring(L, -1).endsWith("you fucked up"),
- "Error is on the stack"
- );
-});
-
-
-test('xpcall', function (t) {
- let luaCode = `
- local willFail = function ()
- error("you fucked up")
- end
-
- local msgh = function (err)
- return "Something's wrong: " .. err
- end
-
- return xpcall(willFail, msgh)
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.ok(
- lua.lua_tojsstring(L, -1).startsWith("Something's wrong:"),
- "msgh was called and modified the error"
- );
-
- t.ok(
- lua.lua_tojsstring(L, -1).endsWith("you fucked up"),
- "msgh was called and modified the error"
- );
-});
-
-
-test('ipairs', function (t) {
- let luaCode = `
- local t = {1, 2, 3, 4, 5, ['yo'] = 'lo'}
-
- local sum = 0
- for i, v in ipairs(t) do
- sum = sum + v
- end
-
- return sum
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 15,
- "Correct element(s) on the stack"
- );
-});
-
-
-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 () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.deepEqual(
- [...lua.lua_topointer(L, -3).strong.entries()].map(e => e[1].value.value),
- [3],
- "Correct element(s) on the stack"
- );
-
- t.deepEqual(
- [...lua.lua_topointer(L, -2).strong.entries()].map(e => e[1].value.value).sort(),
- [2, 3],
- "Correct element(s) on the stack"
- );
-
- t.deepEqual(
- [...lua.lua_topointer(L, -1).strong.entries()].map(e => e[1].value.value).sort(),
- [2, 3],
- "Correct element(s) on the stack"
- );
-});
-
-
-test('tonumber', function (t) {
- let luaCode = `
- return tonumber('foo'),
- tonumber('123'),
- tonumber('12.3'),
- tonumber('az', 36),
- tonumber('10', 2)
- `, L;
-
- t.plan(6);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.ok(
- lua.lua_isnil(L, -5),
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tonumber(L, -4),
- 123,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tonumber(L, -3),
- 12.3,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tonumber(L, -2),
- 395,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tonumber(L, -1),
- 2,
- "Correct element(s) on the stack"
- );
-});
-
-
-test('assert', function (t) {
- let luaCode = `
- assert(1 < 0, "this doesn't makes sense")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_pcall(L, 0, -1, 0);
-
- }, "JS Lua program ran without error");
-
- t.ok(
- lua.lua_tojsstring(L, -1).endsWith("this doesn't makes sense"),
- "Error is on the stack"
- );
-});
-
-
-test('rawlen', function (t) {
- let luaCode = `
- return rawlen({1, 2, 3}), rawlen('hello')
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tonumber(L, -2),
- 3,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tonumber(L, -1),
- 5,
- "Correct element(s) on the stack"
- );
-});
-
-
-test('next', function (t) {
- let luaCode = `
- local total = 0
- local t = {
- 1,
- two = 2,
- 3,
- four = 4
- }
-
- for k,v in next, t, nil do
- total = total + v
- end
-
- return total
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tonumber(L, -1),
- 10,
- "Correct element(s) on the stack"
- );
-});
-
-
-test('pairs', function (t) {
- let luaCode = `
- local total = 0
- local t = {
- 1,
- two = 2,
- 3,
- four = 4
- }
-
- for k,v in pairs(t) do
- total = total + v
- end
-
- return total
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tonumber(L, -1),
- 10,
- "Correct element(s) on the stack"
- );
-});
-
-
-test('pairs with __pairs', function (t) {
- let luaCode = `
- local total = 0
-
- local mt = {
- __pairs = function(t)
- return next, {5, 6, 7, 8}, nil
- end
- }
-
- local t = {
- 1,
- two = 2,
- 3,
- four = 4
- }
-
- setmetatable(t, mt)
-
- for k,v in pairs(t) do
- total = total + v
- end
-
- return total
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tonumber(L, -1),
- 26,
- "Correct element(s) on the stack"
- );
-});
diff --git a/tests/lcorolib.js b/tests/lcorolib.js
deleted file mode 100644
index 42f9677..0000000
--- a/tests/lcorolib.js
+++ /dev/null
@@ -1,201 +0,0 @@
-"use strict";
-
-const test = require('tape');
-
-const lua = require('../src/lua.js');
-const lauxlib = require('../src/lauxlib.js');
-const lualib = require('../src/lualib.js');
-const lstate = require('../src/lstate.js');
-const {to_luastring} = require("../src/fengaricore.js");
-
-test('coroutine.create, coroutine.yield, coroutine.resume', function (t) {
- let luaCode = `
- local co = coroutine.create(function (start)
- local b = coroutine.yield(start * start);
- coroutine.yield(b * b)
- end)
-
- local success, pow = coroutine.resume(co, 5)
- success, pow = coroutine.resume(co, pow)
-
- return pow
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tonumber(L, -1),
- 625,
- "Correct element(s) on the stack"
- );
-});
-
-
-test('coroutine.status', function (t) {
- let luaCode = `
- local co = coroutine.create(function (start)
- local b = coroutine.yield(start * start);
- coroutine.yield(b * b)
- end)
-
- local s1 = coroutine.status(co)
-
- local success, pow = coroutine.resume(co, 5)
- success, pow = coroutine.resume(co, pow)
-
- coroutine.resume(co, pow)
-
- local s2 = coroutine.status(co)
-
- return s1, s2
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -2),
- "suspended",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "dead",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('coroutine.isyieldable', function (t) {
- let luaCode = `
- local co = coroutine.create(function ()
- coroutine.yield(coroutine.isyieldable());
- end)
-
- local succes, yieldable = coroutine.resume(co)
-
- return yieldable, coroutine.isyieldable()
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.ok(
- lua.lua_toboolean(L, -2),
- "Correct element(s) on the stack"
- );
-
- t.notOk(
- lua.lua_toboolean(L, -1),
- "Correct element(s) on the stack"
- );
-});
-
-
-test('coroutine.running', function (t) {
- let luaCode = `
- local running, ismain
-
- local co = coroutine.create(function ()
- running, ismain = coroutine.running()
- end)
-
- coroutine.resume(co)
-
- return running, ismain
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.ok(
- lua.lua_tothread(L, -2) instanceof lstate.lua_State,
- "Correct element(s) on the stack"
- );
-
- t.notOk(
- lua.lua_toboolean(L, -1),
- "Correct element(s) on the stack"
- );
-});
-
-
-test('coroutine.wrap', function (t) {
- let luaCode = `
- local co = coroutine.wrap(function (start)
- local b = coroutine.yield(start * start);
- coroutine.yield(b * b)
- end)
-
- pow = co(5)
- pow = co(pow)
-
- return pow
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tonumber(L, -1),
- 625,
- "Correct element(s) on the stack"
- );
-});
diff --git a/tests/ldblib.js b/tests/ldblib.js
deleted file mode 100644
index 8a30e48..0000000
--- a/tests/ldblib.js
+++ /dev/null
@@ -1,492 +0,0 @@
-"use strict";
-
-const test = require('tape');
-
-const lua = require('../src/lua.js');
-const lauxlib = require('../src/lauxlib.js');
-const lualib = require('../src/lualib.js');
-const {to_luastring} = require("../src/fengaricore.js");
-
-test('debug.sethook', function (t) {
- let luaCode = `
- local result = ""
-
- debug.sethook(function (event)
- result = result .. event .. " "
- end, "crl", 1)
-
- local l = function() end
-
- l()
- l()
- l()
-
- return result
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "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"
- );
-});
-
-
-test('debug.gethook', function (t) {
- let luaCode = `
- local result = ""
-
- debug.sethook(function (event)
- result = result .. event .. " "
- end, "crl", 1)
-
- local l = function() end
-
- l()
- l()
- l()
-
- return debug.gethook()
- `, L;
-
- t.plan(5);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.deepEqual(
- lua.lua_typename(L, lua.lua_type(L, -3)),
- to_luastring("function"),
- "Correct element(s) on the stack"
- );
-
- t.deepEqual(
- lua.lua_tojsstring(L, -2),
- "crl",
- "Correct element(s) on the stack"
- );
-
- t.deepEqual(
- lua.lua_tointeger(L, -1),
- 1,
- "Correct element(s) on the stack"
- );
-});
-
-
-test('debug.getlocal', function (t) {
- let luaCode = `
- local alocal = "alocal"
- local another = "another"
-
- local result = ""
-
- local l = function()
- local infunction = "infunction"
- local anotherin = "anotherin"
- result = table.concat(table.pack(debug.getlocal(2, 1)), " ")
- .. table.concat(table.pack(debug.getlocal(2, 2)), " ")
- .. table.concat(table.pack(debug.getlocal(1, 1)), " ")
- .. table.concat(table.pack(debug.getlocal(1, 2)), " ")
- end
-
- l()
-
- return result
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "alocal alocalanother anotherinfunction infunctionanotherin anotherin",
- "Correct element(s) on the stack"
- );
-});
-
-test('debug.setlocal', function (t) {
- let luaCode = `
- local alocal = "alocal"
- local another = "another"
-
- local l = function()
- local infunction = "infunction"
- local anotherin = "anotherin"
-
- debug.setlocal(2, 1, 1)
- debug.setlocal(2, 2, 2)
- debug.setlocal(1, 1, 3)
- debug.setlocal(1, 2, 4)
-
- return infunction, anotherin
- end
-
- local a, b = l()
-
- return alocal, another, a, b
- `, L;
-
- t.plan(6);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tointeger(L, -4),
- 1,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -3),
- 2,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -2),
- 3,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 4,
- "Correct element(s) on the stack"
- );
-});
-
-test('debug.upvalueid', function (t) {
- let luaCode = `
- local upvalue = "upvalue"
-
- local l = function()
- return upvalue
- end
-
- return debug.upvalueid(l, 1)
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.ok(
- lua.lua_touserdata(L, -1),
- "Correct element(s) on the stack"
- );
-});
-
-
-test('debug.upvaluejoin', function (t) {
- let luaCode = `
- local upvalue1 = "upvalue1"
- local upvalue2 = "upvalue2"
-
- local l1 = function()
- return upvalue1
- end
-
- local l2 = function()
- return upvalue2
- end
-
- debug.upvaluejoin(l1, 1, l2, 1)
-
- return l1()
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "upvalue2",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('debug.traceback (with a global)', function (t) {
- let luaCode = `
- local trace
-
- rec = function(n)
- n = n or 0
- if n < 10 then
- rec(n + 1)
- else
- trace = debug.traceback()
- end
- end
-
- rec()
-
- return trace
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- luaCode = to_luastring(luaCode);
- lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring("traceback-test"));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- 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'
-\t[string "traceback-test"]:7: in function 'rec'
-\t[string "traceback-test"]:7: in function 'rec'
-\t[string "traceback-test"]:7: in function 'rec'
-\t[string "traceback-test"]:7: in function 'rec'
-\t[string "traceback-test"]:7: in function 'rec'
-\t[string "traceback-test"]:7: in function 'rec'
-\t[string "traceback-test"]:7: in function 'rec'
-\t[string "traceback-test"]:7: in function 'rec'
-\t[string "traceback-test"]:13: in main chunk`,
- "Correct element(s) on the stack"
- );
-});
-
-
-test('debug.traceback (with a upvalue)', function (t) {
- let luaCode = `
- local trace
- local rec
-
- rec = function(n)
- n = n or 0
- if n < 10 then
- rec(n + 1)
- else
- trace = debug.traceback()
- end
- end
-
- rec()
-
- return trace
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- luaCode = to_luastring(luaCode);
- lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring("traceback-test"));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- 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'
-\t[string "traceback-test"]:8: in upvalue 'rec'
-\t[string "traceback-test"]:8: in upvalue 'rec'
-\t[string "traceback-test"]:8: in upvalue 'rec'
-\t[string "traceback-test"]:8: in upvalue 'rec'
-\t[string "traceback-test"]:8: in upvalue 'rec'
-\t[string "traceback-test"]:8: in upvalue 'rec'
-\t[string "traceback-test"]:8: in upvalue 'rec'
-\t[string "traceback-test"]:8: in local 'rec'
-\t[string "traceback-test"]:14: in main chunk`,
- "Correct element(s) on the stack"
- );
-});
-
-test('debug.getinfo', function (t) {
- let luaCode = `
- local alocal = function(p1, p2) end
- global = function() return alocal end
-
- local d1 = debug.getinfo(alocal)
- local d2 = debug.getinfo(global)
-
- print(d1.short_src, d1.nups, d1.what, d1.nparams,
- d2.short_src, d2.nups, d2.what, d2.nparams)
-
- 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 () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- luaCode = to_luastring(luaCode);
- lauxlib.luaL_loadbuffer(L, luaCode, luaCode.length, to_luastring("getinfo-test"));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -8),
- `[string "getinfo-test"]`,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -7),
- 0,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -6),
- `Lua`,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -5),
- 2,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -4),
- `[string "getinfo-test"]`,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -3),
- 1,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -2),
- `Lua`,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 0,
- "Correct element(s) on the stack"
- );
-});
diff --git a/tests/ldebug.js b/tests/ldebug.js
deleted file mode 100644
index 49474e9..0000000
--- a/tests/ldebug.js
+++ /dev/null
@@ -1,194 +0,0 @@
-"use strict";
-
-const test = require('tape');
-
-const lua = require('../src/lua.js');
-const lauxlib = require('../src/lauxlib.js');
-const lualib = require('../src/lualib.js');
-const {to_luastring} = require("../src/fengaricore.js");
-
-test('luaG_typeerror', function (t) {
- let luaCode = `
- local a = true
- return #a
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_pcall(L, 0, -1, 0);
-
- }, "JS Lua program ran without error");
-
-
- t.ok(
- lua.lua_tojsstring(L, -1).endsWith("attempt to get length of a boolean value (local 'a')"),
- "Correct error was thrown"
- );
-});
-
-
-test('luaG_typeerror', function (t) {
- let luaCode = `
- local a = true
- return a.yo
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_pcall(L, 0, -1, 0);
-
- }, "JS Lua program ran without error");
-
- t.ok(
- lua.lua_tojsstring(L, -1).endsWith("attempt to index a boolean value (local 'a')"),
- "Correct error was thrown"
- );
-});
-
-
-test('luaG_typeerror', function (t) {
- let luaCode = `
- local a = true
- return a.yo
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_pcall(L, 0, -1, 0);
-
- }, "JS Lua program ran without error");
-
- t.ok(
- lua.lua_tojsstring(L, -1).endsWith("attempt to index a boolean value (local 'a')"),
- "Correct error was thrown"
- );
-});
-
-
-test('luaG_typeerror', function (t) {
- let luaCode = `
- local a = true
- a.yo = 1
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_pcall(L, 0, -1, 0);
-
- }, "JS Lua program ran without error");
-
- t.ok(
- lua.lua_tojsstring(L, -1).endsWith("attempt to index a boolean value (local 'a')"),
- "Correct error was thrown"
- );
-});
-
-
-test('luaG_concaterror', function (t) {
- let luaCode = `
- return {} .. 'hello'
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_pcall(L, 0, -1, 0);
-
- }, "JS Lua program ran without error");
-
- t.ok(
- lua.lua_tojsstring(L, -1).endsWith("attempt to concatenate a table value"),
- "Correct error was thrown"
- );
-});
-
-
-test('luaG_opinterror', function (t) {
- let luaCode = `
- return {} + 'hello'
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_pcall(L, 0, -1, 0);
-
- }, "JS Lua program ran without error");
-
- t.ok(
- lua.lua_tojsstring(L, -1).endsWith("attempt to perform arithmetic on a table value"),
- "Correct error was thrown"
- );
-});
-
-
-test('luaG_tointerror', function (t) {
- let luaCode = `
- return 123.5 & 12
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_pcall(L, 0, -1, 0);
-
- }, "JS Lua program ran without error");
-
- t.ok(
- lua.lua_tojsstring(L, -1).endsWith("number has no integer representation"),
- "Correct error was thrown"
- );
-});
diff --git a/tests/lmathlib.js b/tests/lmathlib.js
deleted file mode 100644
index 1de0f0c..0000000
--- a/tests/lmathlib.js
+++ /dev/null
@@ -1,448 +0,0 @@
-"use strict";
-
-const test = require('tape');
-
-const lua = require('../src/lua.js');
-const lauxlib = require('../src/lauxlib.js');
-const lualib = require('../src/lualib.js');
-const {to_luastring} = require("../src/fengaricore.js");
-
-test('math.abs, math.sin, math.cos, math.tan, math.asin, math.acos, math.atan', function (t) {
- let luaCode = `
- 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 () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tointeger(L, -7),
- 10,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tonumber(L, -6),
- 10.5,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tonumber(L, -5),
- -0.8390715290764524,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tonumber(L, -4),
- 0.6483608274590866,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tonumber(L, -3),
- 1.5707963267948966,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tonumber(L, -2),
- 1.0471975511965979,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tonumber(L, -1),
- 1.4711276743037347,
- "Correct element(s) on the stack"
- );
-});
-
-
-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 () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tointeger(L, -2),
- 11,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 10,
- "Correct element(s) on the stack"
- );
-});
-
-
-test('math.deg, math.rad', function (t) {
- let luaCode = `
- return math.deg(10), math.rad(10)
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tonumber(L, -2),
- 572.9577951308232,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tonumber(L, -1),
- 0.17453292519943295,
- "Correct element(s) on the stack"
- );
-});
-
-
-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 () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tonumber(L, -3),
- 2.302585092994046,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tonumber(L, -2),
- 3.321928094887362,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tonumber(L, -1),
- 1,
- "Correct element(s) on the stack"
- );
-});
-
-
-/* Node.js 6 has incorrect results for Math.exp */
-(parseInt(process.versions.node) > 6 ? test : test.skip)('math.exp', function (t) {
- let luaCode = `
- return math.exp(10)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tonumber(L, -1),
- 22026.465794806718,
- "Correct element(s) on the stack"
- );
-});
-
-
-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 () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tonumber(L, -2),
- 23,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tonumber(L, -1),
- 5,
- "Correct element(s) on the stack"
- );
-});
-
-
-test('math.random', function (t) {
- let luaCode = `
- return math.random(), math.random(10, 15)
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.ok(
- 0 <= lua.lua_tonumber(L, -2) <= 1,
- "Correct element(s) on the stack"
- );
-
- t.ok(
- 10 <= lua.lua_tonumber(L, -1) <= 15,
- "Correct element(s) on the stack"
- );
-});
-
-
-test('math.sqrt', function (t) {
- let luaCode = `
- return math.sqrt(10)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tonumber(L, -1),
- 3.1622776601683795,
- "Correct element(s) on the stack"
- );
-});
-
-
-test('math.tointeger', function (t) {
- let luaCode = `
- return math.tointeger('10')
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tonumber(L, -1),
- 10,
- "Correct element(s) on the stack"
- );
-});
-
-
-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 () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -3),
- "integer",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -2),
- "float",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- null,
- "Correct element(s) on the stack"
- );
-});
-
-
-test('math.ult', function (t) {
- let luaCode = `
- return math.ult(5, 200)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_toboolean(L, -1),
- true,
- "Correct element(s) on the stack"
- );
-});
-
-
-test('math.fmod', function (t) {
- let luaCode = `
- return math.fmod(2,5)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tonumber(L, -1),
- 2,
- "Correct element(s) on the stack"
- );
-});
-
-
-test('math.modf', function (t) {
- let luaCode = `
- return math.modf(3.4, 0.6)
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tonumber(L, -2),
- 3,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tonumber(L, -1),
- 0.3999999999999999,
- "Correct element(s) on the stack"
- );
-});
diff --git a/tests/load.js b/tests/load.js
deleted file mode 100644
index 0eb0ccf..0000000
--- a/tests/load.js
+++ /dev/null
@@ -1,203 +0,0 @@
-"use strict";
-
-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');
-const {to_luastring} = require("../src/fengaricore.js");
-
-test('luaL_loadstring', function (t) {
- let luaCode = `
- local a = "hello world"
- return a
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello world",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('load', function (t) {
- let luaCode = `
- local f = load("return 'js running lua running lua'")
- return f()
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "js running lua running lua",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('luaL_loadbuffer', function (t) {
- let luaCode = `
- local a = "hello world"
- return a
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- let bc = toByteCode(luaCode);
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadbuffer(L, bc, null, to_luastring("test"));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello world",
- "Correct element(s) on the stack"
- );
-});
-
-// TODO: test stdin
-test('loadfile', function (t) {
- let luaCode = `
- local f = assert(loadfile("tests/loadfile-test.lua"))
- return f()
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello world",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('loadfile (binary)', function (t) {
- let luaCode = `
- local f = assert(loadfile("tests/loadfile-test.bc"))
- return f()
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello world",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('dofile', function (t) {
- let luaCode = `
- return dofile("tests/loadfile-test.lua")
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello world",
- "Correct element(s) on the stack"
- );
-});
diff --git a/tests/loadlib.js b/tests/loadlib.js
deleted file mode 100644
index dba2a3a..0000000
--- a/tests/loadlib.js
+++ /dev/null
@@ -1,130 +0,0 @@
-"use strict";
-
-const test = require('tape');
-
-const lua = require('../src/lua.js');
-const lauxlib = require('../src/lauxlib.js');
-const lualib = require('../src/lualib.js');
-const {to_luastring} = require("../src/fengaricore.js");
-
-test('require an existing module', function (t) {
- let luaCode = `
- return require('os')
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.ok(
- lua.lua_istable(L, -1),
- "Correct element(s) on the stack"
- );
-});
-
-
-test('require a file', function (t) {
- let luaCode = `
- return require('tests/module-hello')()
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello from module",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('package.loadlib', function (t) {
- let luaCode = `
- return package.loadlib('./tests/lib-hello.js.mod', 'hello')()
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello from js lib",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('package.searchpath', function (t) {
- let luaCode = `
- return package.searchpath('module-hello', './?.lua;./tests/?.lua')
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "./tests/module-hello.lua",
- "Correct element(s) on the stack"
- );
-});
diff --git a/tests/loslib.js b/tests/loslib.js
deleted file mode 100644
index 904ca9c..0000000
--- a/tests/loslib.js
+++ /dev/null
@@ -1,169 +0,0 @@
-"use strict";
-
-const test = require('tape');
-
-const lua = require('../src/lua.js');
-const lauxlib = require('../src/lauxlib.js');
-const lualib = require('../src/lualib.js');
-const {to_luastring} = require("../src/fengaricore.js");
-
-test('os.time', function (t) {
- let luaCode = `
- return os.time()
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.ok(
- lua.lua_isinteger(L, -1),
- "Correct element(s) on the stack"
- );
-});
-
-
-test('os.time (with format)', function (t) {
- let luaCode = `
- return os.time({
- day = 8,
- month = 2,
- year = 2015
- })
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- new Date(2015, 1, 8, 12, 0, 0, 0).getTime() / 1000,
- "Correct element(s) on the stack"
- );
-});
-
-
-test('os.difftime', function (t) {
- let luaCode = `
- local t1 = os.time()
- local t2 = os.time()
- return os.difftime(t2, t1)
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.ok(
- lua.lua_isnumber(L, -1),
- "Correct element(s) on the stack"
- );
-});
-
-
-test('os.date', function (t) {
- let luaCode = `
- return os.date('%Y-%m-%d', os.time({
- day = 8,
- month = 2,
- year = 2015
- }))
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "2015-02-08",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('os.getenv', function (t) {
- let luaCode = `
- return os.getenv('PATH')
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.ok(
- lua.lua_isstring(L, -1),
- "Correct element(s) on the stack"
- );
-});
diff --git a/tests/lstrlib.js b/tests/lstrlib.js
deleted file mode 100644
index 50e9996..0000000
--- a/tests/lstrlib.js
+++ /dev/null
@@ -1,865 +0,0 @@
-"use strict";
-
-const test = require('tape');
-
-const lua = require('../src/lua.js');
-const lauxlib = require('../src/lauxlib.js');
-const lualib = require('../src/lualib.js');
-const {to_luastring} = require("../src/fengaricore.js");
-
-test('string.len', function (t) {
- let luaCode = `
- local a = "world"
- return string.len("hello"), a:len()
- `, L;
-
- t.plan(4);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tointeger(L, -2),
- 5,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 5,
- "Correct element(s) on the stack"
- );
-
-});
-
-
-test('string.char', function (t) {
- let luaCode = `
- return string.char(104, 101, 108, 108, 111)
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('string.upper, string.lower', function (t) {
- let luaCode = `
- return string.upper("hello"), string.lower("HELLO")
- `, L;
-
- t.plan(4);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -2),
- "HELLO",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('string.rep', function (t) {
- let luaCode = `
- return string.rep("hello", 3, ", ")
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello, hello, hello",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('string.reverse', function (t) {
- let luaCode = `
- return string.reverse("olleh")
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('string.byte', function (t) {
- let luaCode = `
- return string.byte("hello", 2, 4)
- `, L;
-
- t.plan(5);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tointeger(L, -3),
- 101,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -2),
- 108,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 108,
- "Correct element(s) on the stack"
- );
-});
-
-
-test('string.format', function (t) {
- let luaCode = `
- return string.format("%%%d %010d", 10, 23)
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "%10 0000000023",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('string.format', function (t) {
- let luaCode = `
- return string.format("%07X", 0xFFFFFFF)
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "FFFFFFF",
- "Correct element(s) on the stack"
- );
-});
-
-
-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 () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- '"a string with \\"quotes\\" and \\\n new line"',
- "Correct element(s) on the stack"
- );
-});
-
-
-test('string.sub', function (t) {
- let luaCode = `
- return string.sub("123456789",2,4), -- "234"
- string.sub("123456789",7), -- "789"
- string.sub("123456789",7,6), -- ""
- string.sub("123456789",7,7), -- "7"
- string.sub("123456789",0,0), -- ""
- string.sub("123456789",-10,10), -- "123456789"
- string.sub("123456789",1,9), -- "123456789"
- string.sub("123456789",-10,-20), -- ""
- string.sub("123456789",-1), -- "9"
- string.sub("123456789",-4), -- "6789"
- string.sub("123456789",-6, -4) -- "456"
- `, L;
-
- t.plan(13);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -11),
- "234",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -10),
- "789",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -9),
- "",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -8),
- "7",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -7),
- "",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -6),
- "123456789",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -5),
- "123456789",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -4),
- "",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -3),
- "9",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -2),
- "6789",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "456",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('string.dump', function (t) {
- let luaCode = `
- local todump = function()
- local s = "hello"
- local i = 12
- local f = 12.5
- local b = true
-
- return s .. i .. f
- end
-
- return string.dump(todump)
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode.trim()));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- let str = lua.lua_tostring(L, -1);
-
- lua.lua_load(L, function(L, s) { let r = s.str; s.str = null; return r; }, {str: str}, to_luastring("test"), to_luastring("binary"));
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello1212.5",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('string.pack/unpack/packsize', function (t) {
- let luaCode = `
- local s1, n, s2 = "hello", 2, "you"
- local packed = string.pack("c5jc3", s1, n, s2)
- 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 () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tointeger(L, -2),
- 12,
- "Correct element(s) on the stack"
- );
-
- t.ok(
- lua.lua_toboolean(L, -1),
- "Correct element(s) on the stack"
- );
-});
-
-
-test('string.find without pattern', function (t) {
- let luaCode = `
- return string.find("hello to you", " to ")
- `, L;
-
- t.plan(4);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tointeger(L, -2),
- 6,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 9,
- "Correct element(s) on the stack"
- );
-});
-
-
-test('string.match', function (t) {
- let luaCode = `
- return string.match("foo: 123 bar: 456", "(%a+):%s*(%d+)")
- `, L;
-
- t.plan(4);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -2),
- "foo",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "123",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('string.find', function (t) {
- let luaCode = `
- return string.find("foo: 123 bar: 456", "(%a+):%s*(%d+)")
- `, L;
-
- t.plan(6);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tointeger(L, -4),
- 1,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -3),
- 8,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -2),
- "foo",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "123",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('string.gmatch', function (t) {
- let luaCode = `
- local s = "hello world from Lua"
- local t = {}
-
- for w in string.gmatch(s, "%a+") do
- table.insert(t, w)
- end
-
- return table.unpack(t)
- `, L;
-
- t.plan(6);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -4),
- "hello",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -3),
- "world",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -2),
- "from",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "Lua",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('string.gsub', function (t) {
- let luaCode = `
- return string.gsub("hello world", "(%w+)", "%1 %1")
- `, L;
-
- t.plan(4);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -2),
- "hello hello world world",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 2,
- "Correct element(s) on the stack"
- );
-});
-
-
-test('string.gsub (number)', function (t) {
- let luaCode = `
- return string.gsub("hello world", "%w+", "%0 %0", 1)
- `, L;
-
- t.plan(4);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -2),
- "hello hello world",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 1,
- "Correct element(s) on the stack"
- );
-});
-
-
-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 () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -2),
- "world hello Lua from",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 2,
- "Correct element(s) on the stack"
- );
-});
-
-
-test('string.gsub (function)', function (t) {
- let luaCode = `
- return string.gsub("4+5 = $return 4+5$", "%$(.-)%$", function (s)
- return load(s)()
- end)
- `, L;
-
- t.plan(4);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -2),
- "4+5 = 9",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 1,
- "Correct element(s) on the stack"
- );
-});
-
-
-
-test('string.gsub (table)', function (t) {
- let luaCode = `
- local t = {name="lua", version="5.3"}
- return string.gsub("$name-$version.tar.gz", "%$(%w+)", t)
- `, L;
-
- t.plan(4);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -2),
- "lua-5.3.tar.gz",
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 2,
- "Correct element(s) on the stack"
- );
-});
diff --git a/tests/ltablib.js b/tests/ltablib.js
deleted file mode 100644
index 660ac85..0000000
--- a/tests/ltablib.js
+++ /dev/null
@@ -1,268 +0,0 @@
-"use strict";
-
-const test = require('tape');
-
-const lua = require('../src/lua.js');
-const lauxlib = require('../src/lauxlib.js');
-const lualib = require('../src/lualib.js');
-const {to_luastring} = require("../src/fengaricore.js");
-
-const inttable2array = function(t) {
- let a = [];
-
- t.strong.forEach(function (v, k) {
- if (v.key.ttisnumber())
- a[k - 1] = v.value;
- });
-
- return a.map(e => e.value);
-};
-
-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 () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "3,4,5",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('table.pack', function (t) {
- let luaCode = `
- return table.pack(1, 2, 3)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.deepEqual(
- [...lua.lua_topointer(L, -1).strong.entries()]
- .filter(e => e[1].key.ttisnumber()) // Filter out the 'n' field
- .map(e => e[1].value.value).reverse(),
- [1, 2, 3],
- "Correct element(s) on the stack"
- );
-});
-
-
-test('table.unpack', function (t) {
- let luaCode = `
- return table.unpack({1, 2, 3, 4, 5}, 2, 4)
- `, L;
-
- t.plan(4);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tointeger(L, -3),
- 2,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -2),
- 3,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 4,
- "Correct element(s) on the stack"
- );
-});
-
-
-test('table.insert', function (t) {
- let luaCode = `
- local t = {1, 3, 4}
- table.insert(t, 5)
- table.insert(t, 2, 2)
- return t
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.deepEqual(
- [...lua.lua_topointer(L, -1).strong.entries()]
- .filter(e => e[1].key.ttisnumber())
- .map(e => e[1].value.value).sort(),
- [1, 2, 3, 4, 5],
- "Correct element(s) on the stack"
- );
-});
-
-
-test('table.remove', function (t) {
- let luaCode = `
- local t = {1, 2, 3, 3, 4, 4}
- table.remove(t)
- table.remove(t, 3)
- return t
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.deepEqual(
- [...lua.lua_topointer(L, -1).strong.entries()]
- .filter(e => e[1].key.ttisnumber())
- .map(e => e[1].value.value).sort(),
- [1, 2, 3, 4],
- "Correct element(s) on the stack"
- );
-});
-
-
-test('table.move', function (t) {
- let luaCode = `
- local t1 = {3, 4, 5}
- local t2 = {1, 2, nil, nil, nil, 6}
- return table.move(t1, 1, #t1, 3, t2)
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.deepEqual(
- [...lua.lua_topointer(L, -1).strong.entries()]
- .filter(e => e[1].key.ttisnumber())
- .map(e => e[1].value.value).sort(),
- [1, 2, 3, 4, 5, 6],
- "Correct element(s) on the stack"
- );
-});
-
-
-test('table.sort (<)', function (t) {
- let luaCode = `
- local t = {3, 1, 5, ['just'] = 'tofuckitup', 2, 4}
- table.sort(t)
- return t
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.deepEqual(
- inttable2array(lua.lua_topointer(L, -1)),
- [1, 2, 3, 4, 5],
- "Correct element(s) on the stack"
- );
-});
-
-
-test('table.sort with cmp function', function (t) {
- let luaCode = `
- local t = {3, 1, 5, ['just'] = 'tofuckitup', 2, 4}
- table.sort(t, function (a, b)
- return a > b
- end)
- return t
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- lua.lua_call(L, 0, -1);
-
- }, "JS Lua program ran without error");
-
- t.deepEqual(
- inttable2array(lua.lua_topointer(L, -1)),
- [5, 4, 3, 2, 1],
- "Correct element(s) on the stack"
- );
-});
diff --git a/tests/ltm.js b/tests/ltm.js
deleted file mode 100644
index 156d63b..0000000
--- a/tests/ltm.js
+++ /dev/null
@@ -1,732 +0,0 @@
-"use strict";
-
-const test = require('tape');
-
-const lua = require('../src/lua.js');
-const lauxlib = require('../src/lauxlib.js');
-const lualib = require('../src/lualib.js');
-const {to_luastring} = require("../src/fengaricore.js");
-
-test('__index, __newindex: with actual table', function (t) {
- let luaCode = `
- local t = {yo=1}
- return t.yo, t.lo
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
- lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
-
- t.ok(
- lua.lua_isnil(L, -1),
- "Program output is correct"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -2),
- 1,
- "Program output is correct"
- );
-});
-
-
-test('__newindex: with non table', function (t) {
- let luaCode = `
- local t = "a string"
- t.yo = "hello"
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
- }, "Bytecode parsed without errors");
-
- t.throws(function () {
- lua.lua_call(L, 0, -1);
- }, "Program executed with expected error");
-});
-
-
-test('__index function in metatable', function (t) {
- let luaCode = `
- local mt = {
- __index = function (table, key)
- return "__index"
- end
- }
-
- local t = {}
-
- setmetatable(t, mt)
-
- return t.yo
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
- }, "Bytecode parsed without errors");
-
-
- t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "__index",
- "Program output is correct"
- );
-});
-
-
-test('__newindex function in metatable', function (t) {
- let luaCode = `
- local mt = {
- __newindex = function (table, key, value)
- return "__newindex"
- end
- }
-
- local t = {}
-
- setmetatable(t, mt)
-
- t.yo = "hello"
-
- return t.yo
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
- }, "Bytecode parsed without errors");
-
- t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
-
- t.ok(
- lua.lua_isnil(L, -1),
- "Program output is correct"
- );
-});
-
-
-test('__index table in metatable', function (t) {
- let luaCode = `
- local mmt = {
- yo = "hello"
- }
-
- local mt = {
- __index = mmt
- }
-
- local t = {}
-
- setmetatable(t, mt)
-
- return t.yo
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
- }, "Bytecode parsed without errors");
-
- t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello",
- "Program output is correct"
- );
-});
-
-
-test('__newindex table in metatable', function (t) {
- let luaCode = `
- local mmt = {
- yo = "hello"
- }
-
- local mt = {
- __newindex = mmt
- }
-
- local t = {}
-
- setmetatable(t, mt)
-
- t.yo = "world"
-
- return t.yo, mmt.yo
- `, L;
-
- t.plan(4);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
- }, "Bytecode parsed without errors");
-
- t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "world",
- "Program output is correct"
- );
-
- t.ok(
- lua.lua_isnil(L, -2),
- "Program output is correct"
- );
-});
-
-
-test('__index table with own metatable', function (t) {
- let luaCode = `
- local mmmt = {
- __index = function (t, k)
- return "hello"
- end
- }
-
- local mmt = {
- yoo = "bye"
- }
-
- setmetatable(mmt, mmmt)
-
- local mt = {
- __index = mmt
- }
-
- local t = {}
-
- setmetatable(t, mt)
-
- return t.yo
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
- }, "Bytecode parsed without errors");
-
- t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello",
- "Program output is correct"
- );
-});
-
-
-test('__newindex table with own metatable', function (t) {
- let luaCode = `
- local up = nil
-
- local mmmt = {
- __newindex = function (t, k, v)
- up = v
- end
- }
-
- local mmt = {}
-
- setmetatable(mmt, mmmt)
-
- local mt = {
- __newindex = mmt
- }
-
- setmetatable(mt, mmt)
-
- local t = {}
-
- setmetatable(t, mt)
-
- t.yo = "hello"
-
- return t.yo, up
- `, L;
-
- t.plan(4);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
- }, "Bytecode parsed without errors");
-
- t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello",
- "Program output is correct"
- );
-
- t.ok(
- lua.lua_isnil(L, -2),
- "Program output is correct"
- );
-});
-
-
-test('binary __xxx functions in metatable', function (t) {
- let luaCode = `
- local mt = {
- __add = function (a, b)
- return "{} + " .. b
- end,
-
- __sub = function (a, b)
- return "{} - " .. b
- end,
-
- __mul = function (a, b)
- return "{} * " .. b
- end,
-
- __mod = function (a, b)
- return "{} % " .. b
- end,
-
- __pow = function (a, b)
- return "{} ^ " .. b
- end,
-
- __div = function (a, b)
- return "{} / " .. b
- end,
-
- __idiv = function (a, b)
- return "{} // " .. b
- end,
-
- __band = function (a, b)
- return "{} & " .. b
- end,
-
- __bor = function (a, b)
- return "{} | " .. b
- end,
-
- __bxor = function (a, b)
- return "{} ~ " .. b
- end,
-
- __shl = function (a, b)
- return "{} << " .. b
- end,
-
- __shr = function (a, b)
- return "{} >> " .. b
- end
-
- }
-
- local t = {}
-
- setmetatable(t, mt)
-
- return
- t + 1,
- t - 1,
- t * 1,
- t % 1,
- t ^ 1,
- t / 1,
- t // 1,
- t & 1,
- t | 1,
- t ~ 1,
- t << 1,
- t >> 1
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
- }, "Bytecode parsed without errors");
-
- t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
-
- t.deepEqual(
- L.stack.slice(L.top - 12, L.top).map(e => e.jsstring()),
- [
- "{} + 1",
- "{} - 1",
- "{} * 1",
- "{} % 1",
- "{} ^ 1",
- "{} / 1",
- "{} // 1",
- "{} & 1",
- "{} | 1",
- "{} ~ 1",
- "{} << 1",
- "{} >> 1"
- ],
- "Program output is correct"
- );
-});
-
-
-test('__eq', function (t) {
- let luaCode = `
- local mt = {
- __eq = function (a, b)
- return true
- end
- }
-
- local t = {}
-
- setmetatable(t, mt)
-
- return t == {}
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
- }, "Bytecode parsed without errors");
-
- t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
-
- t.ok(
- lua.lua_toboolean(L, -1),
- "Program output is correct"
- );
-});
-
-
-test('__lt', function (t) {
- let luaCode = `
- local mt = {
- __lt = function (a, b)
- return true
- end
- }
-
- local t = {}
-
- setmetatable(t, mt)
-
- return t < {}
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
- }, "Bytecode parsed without errors");
-
- t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
-
- t.ok(
- lua.lua_toboolean(L, -1),
- "Program output is correct"
- );
-});
-
-
-test('__le', function (t) {
- let luaCode = `
- local mt = {
- __le = function (a, b)
- return true
- end
- }
-
- local t = {}
-
- setmetatable(t, mt)
-
- return t <= {}
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
- }, "Bytecode parsed without errors");
-
- t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
-
- t.ok(
- lua.lua_toboolean(L, -1),
- "Program output is correct"
- );
-});
-
-
-test('__le that uses __lt', function (t) {
- let luaCode = `
- local mt = {
- __lt = function (a, b)
- return false
- end
- }
-
- local t = {}
-
- setmetatable(t, mt)
-
- return {} <= t
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
- }, "Bytecode parsed without errors");
-
- t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
-
- t.ok(
- lua.lua_toboolean(L, -1),
- "Program output is correct"
- );
-});
-
-
-test('__unm, __bnot', function (t) {
- let luaCode = `
- local mt = {
- __unm = function (a)
- return "hello"
- end,
-
- __bnot = function (a)
- return "world"
- end
- }
-
- local t = {}
-
- setmetatable(t, mt)
-
- return -t, ~t
- `, L;
-
- t.plan(4);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
- }, "Bytecode parsed without errors");
-
- t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "world",
- "Program output is correct"
- );
-
- t.strictEqual(
- lua.lua_tojsstring(L, -2),
- "hello",
- "Program output is correct"
- );
-});
-
-
-test('__len', function (t) {
- let luaCode = `
- local mt = {
- __len = function (a)
- return "hello"
- end
- }
-
- local t = {}
-
- setmetatable(t, mt)
-
- return #t
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
- }, "Bytecode parsed without errors");
-
- t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello",
- "Program output is correct"
- );
-});
-
-
-test('__concat', function (t) {
- let luaCode = `
- local mt = {
- __concat = function (a)
- return "hello"
- end
- }
-
- local t = {}
-
- setmetatable(t, mt)
-
- return t .. " world"
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
- }, "Bytecode parsed without errors");
-
- t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "hello",
- "Program output is correct"
- );
-});
-
-
-test('__call', function (t) {
- let luaCode = `
- local mt = {
- __call = function (a, ...)
- return "hello", ...
- end
- }
-
- local t = {}
-
- setmetatable(t, mt)
-
- return t("world","wow")
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
- }, "Bytecode parsed without errors");
-
- t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
- }, "Program executed without errors");
-
- t.deepEqual(
- L.stack.slice(L.top - 3, L.top).map(e => e.jsstring()),
- ["hello", "world", "wow"],
- "Program output is correct"
- );
-});
diff --git a/tests/lua.js b/tests/lua.js
deleted file mode 100644
index 0d9cf2e..0000000
--- a/tests/lua.js
+++ /dev/null
@@ -1,87 +0,0 @@
-"use strict";
-
-const test = require('tape');
-
-const lua = require('../src/lua.js');
-const lauxlib = require('../src/lauxlib.js');
-const lualib = require('../src/lualib.js');
-const {to_luastring} = require("../src/fengaricore.js");
-
-// TODO: remove
-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.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-});
-
-
-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.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-});
-
-
-test.skip('strings.lua', function (t) {
- let luaCode = `
- return dofile("tests/lua-tests/strings.lua")
- `, L;
-
- t.plan(2);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-});
diff --git a/tests/lutf8lib.js b/tests/lutf8lib.js
deleted file mode 100644
index baccceb..0000000
--- a/tests/lutf8lib.js
+++ /dev/null
@@ -1,179 +0,0 @@
-"use strict";
-
-const test = require('tape');
-
-const lua = require("../src/lua.js");
-const lauxlib = require("../src/lauxlib.js");
-const lualib = require("../src/lualib.js");
-const {to_luastring} = require("../src/fengaricore.js");
-
-test('utf8.offset', function (t) {
- let luaCode = `
- return utf8.offset("( ͡° ͜ʖ ͡° )", 5)
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 7,
- "Correct element(s) on the stack"
- );
-});
-
-
-test('utf8.codepoint', function (t) {
- let luaCode = `
- return utf8.codepoint("( ͡° ͜ʖ ͡° )", 5, 8)
- `, L;
-
- t.plan(5);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tointeger(L, -3),
- 176,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -2),
- 32,
- "Correct element(s) on the stack"
- );
-
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 860,
- "Correct element(s) on the stack"
- );
-});
-
-
-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 () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tojsstring(L, -1),
- "( ͡° ͜ʖ ͡° )",
- "Correct element(s) on the stack"
- );
-});
-
-
-test('utf8.len', function (t) {
- let luaCode = `
- return utf8.len("( ͡° ͜ʖ ͡° )")
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.lua_tointeger(L, -1),
- 12,
- "Correct element(s) on the stack"
- );
-});
-
-
-test('utf8.codes', function (t) {
- let luaCode = `
- local s = "( ͡° ͜ʖ ͡° )"
- local results = ""
- for p, c in utf8.codes(s) do
- results = results .. "[" .. p .. "," .. c .. "] "
- end
- return results
- `, L;
-
- t.plan(3);
-
- t.doesNotThrow(function () {
-
- L = lauxlib.luaL_newstate();
-
- lualib.luaL_openlibs(L);
-
- lauxlib.luaL_loadstring(L, to_luastring(luaCode));
-
- }, "Lua program loaded without error");
-
- t.doesNotThrow(function () {
-
- lua.lua_call(L, 0, -1);
-
- }, "Lua program ran without error");
-
- t.strictEqual(
- lua.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"
- );
-});
diff --git a/yarn.lock b/yarn.lock
index fa10fdf..15b2d0a 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2,6 +2,34 @@
# yarn lockfile v1
+"@babel/code-frame@^7.0.0-beta.35":
+ version "7.0.0-beta.42"
+ resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0-beta.42.tgz#a9c83233fa7cd06b39dc77adbb908616ff4f1962"
+ dependencies:
+ "@babel/highlight" "7.0.0-beta.42"
+
+"@babel/highlight@7.0.0-beta.42":
+ version "7.0.0-beta.42"
+ resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.0.0-beta.42.tgz#a502a1c0d6f99b2b0e81d468a1b0c0e81e3f3623"
+ dependencies:
+ chalk "^2.0.0"
+ esutils "^2.0.2"
+ js-tokens "^3.0.0"
+
+abab@^1.0.4:
+ version "1.0.4"
+ resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.4.tgz#5faad9c2c07f60dd76770f71cf025b62a63cfd4e"
+
+abbrev@1:
+ version "1.1.1"
+ resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8"
+
+acorn-globals@^4.1.0:
+ version "4.1.0"
+ resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-4.1.0.tgz#ab716025dbe17c54d3ef81d32ece2b2d99fe2538"
+ dependencies:
+ acorn "^5.0.0"
+
acorn-jsx@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-3.0.1.tgz#afdf9488fb1ecefc8348f6fb22f464e32a58b36b"
@@ -12,7 +40,7 @@ acorn@^3.0.4:
version "3.3.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a"
-acorn@^5.5.0:
+acorn@^5.0.0, acorn@^5.3.0, acorn@^5.5.0:
version "5.5.3"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.5.3.tgz#f473dd47e0277a08e28e9bec5aeeb04751f0b8c9"
@@ -20,7 +48,14 @@ ajv-keywords@^2.1.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.1.tgz#617997fc5f60576894c435f940d819e135b80762"
-ajv@^5.2.3, ajv@^5.3.0:
+ajv@^4.9.1:
+ version "4.11.8"
+ resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536"
+ dependencies:
+ co "^4.6.0"
+ json-stable-stringify "^1.0.1"
+
+ajv@^5.1.0, ajv@^5.2.3, ajv@^5.3.0:
version "5.5.2"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965"
dependencies:
@@ -29,6 +64,18 @@ ajv@^5.2.3, ajv@^5.3.0:
fast-json-stable-stringify "^2.0.0"
json-schema-traverse "^0.3.0"
+align-text@^0.1.1, align-text@^0.1.3:
+ version "0.1.4"
+ resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117"
+ dependencies:
+ kind-of "^3.0.2"
+ longest "^1.0.1"
+ repeat-string "^1.5.2"
+
+amdefine@>=0.0.4:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5"
+
ansi-escapes@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.1.0.tgz#f73207bb81207d75fd6c83f125af26eea378ca30"
@@ -45,18 +92,64 @@ ansi-styles@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe"
-ansi-styles@^3.2.1:
+ansi-styles@^3.2.0, ansi-styles@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d"
dependencies:
color-convert "^1.9.0"
+anymatch@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-2.0.0.tgz#bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb"
+ dependencies:
+ micromatch "^3.1.4"
+ normalize-path "^2.1.1"
+
+append-transform@^0.4.0:
+ version "0.4.0"
+ resolved "https://registry.yarnpkg.com/append-transform/-/append-transform-0.4.0.tgz#d76ebf8ca94d276e247a36bad44a4b74ab611991"
+ dependencies:
+ default-require-extensions "^1.0.0"
+
+aproba@^1.0.3:
+ version "1.2.0"
+ resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a"
+
+are-we-there-yet@~1.1.2:
+ version "1.1.4"
+ resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz#bb5dca382bb94f05e15194373d16fd3ba1ca110d"
+ dependencies:
+ delegates "^1.0.0"
+ readable-stream "^2.0.6"
+
argparse@^1.0.7:
version "1.0.10"
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
dependencies:
sprintf-js "~1.0.2"
+arr-diff@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf"
+ dependencies:
+ arr-flatten "^1.0.1"
+
+arr-diff@^4.0.0:
+ version "4.0.0"
+ resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520"
+
+arr-flatten@^1.0.1, arr-flatten@^1.1.0:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1"
+
+arr-union@^3.1.0:
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4"
+
+array-equal@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/array-equal/-/array-equal-1.0.0.tgz#8c2a5ef2472fd9ea742b04c77a75093ba2757c93"
+
array-union@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39"
@@ -67,11 +160,73 @@ array-uniq@^1.0.1:
version "1.0.3"
resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6"
-arrify@^1.0.0:
+array-unique@^0.2.1:
+ version "0.2.1"
+ resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53"
+
+array-unique@^0.3.2:
+ version "0.3.2"
+ resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428"
+
+arrify@^1.0.0, arrify@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d"
-babel-code-frame@^6.22.0:
+asn1@~0.2.3:
+ version "0.2.3"
+ resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.3.tgz#dac8787713c9966849fc8180777ebe9c1ddf3b86"
+
+assert-plus@1.0.0, assert-plus@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525"
+
+assert-plus@^0.2.0:
+ version "0.2.0"
+ resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234"
+
+assign-symbols@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367"
+
+astral-regex@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-1.0.0.tgz#6c8c3fb827dd43ee3918f27b82782ab7658a6fd9"
+
+async-limiter@~1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.0.tgz#78faed8c3d074ab81f22b4e985d79e8738f720f8"
+
+async@^1.4.0:
+ version "1.5.2"
+ resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"
+
+async@^2.1.4:
+ version "2.6.0"
+ resolved "https://registry.yarnpkg.com/async/-/async-2.6.0.tgz#61a29abb6fcc026fea77e56d1c6ec53a795951f4"
+ dependencies:
+ lodash "^4.14.0"
+
+asynckit@^0.4.0:
+ version "0.4.0"
+ resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
+
+atob@^2.0.0:
+ version "2.1.0"
+ resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.0.tgz#ab2b150e51d7b122b9efc8d7340c06b6c41076bc"
+
+aws-sign2@~0.6.0:
+ version "0.6.0"
+ resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f"
+
+aws-sign2@~0.7.0:
+ version "0.7.0"
+ resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8"
+
+aws4@^1.2.1, aws4@^1.6.0:
+ version "1.6.0"
+ resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e"
+
+babel-code-frame@^6.22.0, babel-code-frame@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b"
dependencies:
@@ -79,10 +234,188 @@ babel-code-frame@^6.22.0:
esutils "^2.0.2"
js-tokens "^3.0.2"
+babel-core@^6.0.0, babel-core@^6.26.0:
+ version "6.26.0"
+ resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.26.0.tgz#af32f78b31a6fcef119c87b0fd8d9753f03a0bb8"
+ dependencies:
+ babel-code-frame "^6.26.0"
+ babel-generator "^6.26.0"
+ babel-helpers "^6.24.1"
+ babel-messages "^6.23.0"
+ babel-register "^6.26.0"
+ babel-runtime "^6.26.0"
+ babel-template "^6.26.0"
+ babel-traverse "^6.26.0"
+ babel-types "^6.26.0"
+ babylon "^6.18.0"
+ convert-source-map "^1.5.0"
+ debug "^2.6.8"
+ json5 "^0.5.1"
+ lodash "^4.17.4"
+ minimatch "^3.0.4"
+ path-is-absolute "^1.0.1"
+ private "^0.1.7"
+ slash "^1.0.0"
+ source-map "^0.5.6"
+
+babel-generator@^6.18.0, babel-generator@^6.26.0:
+ version "6.26.1"
+ resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.26.1.tgz#1844408d3b8f0d35a404ea7ac180f087a601bd90"
+ dependencies:
+ babel-messages "^6.23.0"
+ babel-runtime "^6.26.0"
+ babel-types "^6.26.0"
+ detect-indent "^4.0.0"
+ jsesc "^1.3.0"
+ lodash "^4.17.4"
+ source-map "^0.5.7"
+ trim-right "^1.0.1"
+
+babel-helpers@^6.24.1:
+ version "6.24.1"
+ resolved "https://registry.yarnpkg.com/babel-helpers/-/babel-helpers-6.24.1.tgz#3471de9caec388e5c850e597e58a26ddf37602b2"
+ dependencies:
+ babel-runtime "^6.22.0"
+ babel-template "^6.24.1"
+
+babel-jest@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-22.4.3.tgz#4b7a0b6041691bbd422ab49b3b73654a49a6627a"
+ dependencies:
+ babel-plugin-istanbul "^4.1.5"
+ babel-preset-jest "^22.4.3"
+
+babel-messages@^6.23.0:
+ version "6.23.0"
+ resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e"
+ dependencies:
+ babel-runtime "^6.22.0"
+
+babel-plugin-istanbul@^4.1.5:
+ version "4.1.5"
+ resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.5.tgz#6760cdd977f411d3e175bb064f2bc327d99b2b6e"
+ dependencies:
+ find-up "^2.1.0"
+ istanbul-lib-instrument "^1.7.5"
+ test-exclude "^4.1.1"
+
+babel-plugin-jest-hoist@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-22.4.3.tgz#7d8bcccadc2667f96a0dcc6afe1891875ee6c14a"
+
+babel-plugin-syntax-object-rest-spread@^6.13.0:
+ version "6.13.0"
+ resolved "https://registry.yarnpkg.com/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz#fd6536f2bce13836ffa3a5458c4903a597bb3bf5"
+
+babel-preset-jest@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-22.4.3.tgz#e92eef9813b7026ab4ca675799f37419b5a44156"
+ dependencies:
+ babel-plugin-jest-hoist "^22.4.3"
+ babel-plugin-syntax-object-rest-spread "^6.13.0"
+
+babel-register@^6.26.0:
+ version "6.26.0"
+ resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.26.0.tgz#6ed021173e2fcb486d7acb45c6009a856f647071"
+ dependencies:
+ babel-core "^6.26.0"
+ babel-runtime "^6.26.0"
+ core-js "^2.5.0"
+ home-or-tmp "^2.0.0"
+ lodash "^4.17.4"
+ mkdirp "^0.5.1"
+ source-map-support "^0.4.15"
+
+babel-runtime@^6.22.0, babel-runtime@^6.26.0:
+ version "6.26.0"
+ resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe"
+ dependencies:
+ core-js "^2.4.0"
+ regenerator-runtime "^0.11.0"
+
+babel-template@^6.16.0, babel-template@^6.24.1, babel-template@^6.26.0:
+ version "6.26.0"
+ resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.26.0.tgz#de03e2d16396b069f46dd9fff8521fb1a0e35e02"
+ dependencies:
+ babel-runtime "^6.26.0"
+ babel-traverse "^6.26.0"
+ babel-types "^6.26.0"
+ babylon "^6.18.0"
+ lodash "^4.17.4"
+
+babel-traverse@^6.18.0, babel-traverse@^6.26.0:
+ version "6.26.0"
+ resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee"
+ dependencies:
+ babel-code-frame "^6.26.0"
+ babel-messages "^6.23.0"
+ babel-runtime "^6.26.0"
+ babel-types "^6.26.0"
+ babylon "^6.18.0"
+ debug "^2.6.8"
+ globals "^9.18.0"
+ invariant "^2.2.2"
+ lodash "^4.17.4"
+
+babel-types@^6.18.0, babel-types@^6.26.0:
+ version "6.26.0"
+ resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497"
+ dependencies:
+ babel-runtime "^6.26.0"
+ esutils "^2.0.2"
+ lodash "^4.17.4"
+ to-fast-properties "^1.0.3"
+
+babylon@^6.18.0:
+ version "6.18.0"
+ resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3"
+
balanced-match@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
+base@^0.11.1:
+ version "0.11.2"
+ resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f"
+ dependencies:
+ cache-base "^1.0.1"
+ class-utils "^0.3.5"
+ component-emitter "^1.2.1"
+ define-property "^1.0.0"
+ isobject "^3.0.1"
+ mixin-deep "^1.2.0"
+ pascalcase "^0.1.1"
+
+bcrypt-pbkdf@^1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz#63bc5dcb61331b92bc05fd528953c33462a06f8d"
+ dependencies:
+ tweetnacl "^0.14.3"
+
+block-stream@*:
+ version "0.0.9"
+ resolved "https://registry.yarnpkg.com/block-stream/-/block-stream-0.0.9.tgz#13ebfe778a03205cfe03751481ebb4b3300c126a"
+ dependencies:
+ inherits "~2.0.0"
+
+boom@2.x.x:
+ version "2.10.1"
+ resolved "https://registry.yarnpkg.com/boom/-/boom-2.10.1.tgz#39c8918ceff5799f83f9492a848f625add0c766f"
+ dependencies:
+ hoek "2.x.x"
+
+boom@4.x.x:
+ version "4.3.1"
+ resolved "https://registry.yarnpkg.com/boom/-/boom-4.3.1.tgz#4f8a3005cb4a7e3889f749030fd25b96e01d2e31"
+ dependencies:
+ hoek "4.x.x"
+
+boom@5.x.x:
+ version "5.2.0"
+ resolved "https://registry.yarnpkg.com/boom/-/boom-5.2.0.tgz#5dd9da6ee3a5f302077436290cb717d3f4a54e02"
+ dependencies:
+ hoek "4.x.x"
+
brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
@@ -90,10 +423,69 @@ brace-expansion@^1.1.7:
balanced-match "^1.0.0"
concat-map "0.0.1"
+braces@^1.8.2:
+ version "1.8.5"
+ resolved "https://registry.yarnpkg.com/braces/-/braces-1.8.5.tgz#ba77962e12dff969d6b76711e914b737857bf6a7"
+ dependencies:
+ expand-range "^1.8.1"
+ preserve "^0.2.0"
+ repeat-element "^1.1.2"
+
+braces@^2.3.1:
+ version "2.3.1"
+ resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.1.tgz#7086c913b4e5a08dbe37ac0ee6a2500c4ba691bb"
+ dependencies:
+ arr-flatten "^1.1.0"
+ array-unique "^0.3.2"
+ define-property "^1.0.0"
+ extend-shallow "^2.0.1"
+ fill-range "^4.0.0"
+ isobject "^3.0.1"
+ kind-of "^6.0.2"
+ repeat-element "^1.1.2"
+ snapdragon "^0.8.1"
+ snapdragon-node "^2.0.1"
+ split-string "^3.0.2"
+ to-regex "^3.0.1"
+
+browser-process-hrtime@^0.1.2:
+ version "0.1.2"
+ resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-0.1.2.tgz#425d68a58d3447f02a04aa894187fce8af8b7b8e"
+
+browser-resolve@^1.11.2:
+ version "1.11.2"
+ resolved "https://registry.yarnpkg.com/browser-resolve/-/browser-resolve-1.11.2.tgz#8ff09b0a2c421718a1051c260b32e48f442938ce"
+ dependencies:
+ resolve "1.1.7"
+
+bser@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/bser/-/bser-2.0.0.tgz#9ac78d3ed5d915804fd87acb158bc797147a1719"
+ dependencies:
+ node-int64 "^0.4.0"
+
buffer-from@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.0.0.tgz#4cb8832d23612589b0406e9e2956c17f06fdf531"
+builtin-modules@^1.0.0:
+ version "1.1.1"
+ resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f"
+
+cache-base@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/cache-base/-/cache-base-1.0.1.tgz#0a7f46416831c8b662ee36fe4e7c59d76f666ab2"
+ dependencies:
+ collection-visit "^1.0.0"
+ component-emitter "^1.2.1"
+ get-value "^2.0.6"
+ has-value "^1.0.0"
+ isobject "^3.0.1"
+ set-value "^2.0.0"
+ to-object-path "^0.3.0"
+ union-value "^1.0.0"
+ unset-value "^1.0.0"
+
caller-path@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/caller-path/-/caller-path-0.1.0.tgz#94085ef63581ecd3daa92444a8fe94e82577751f"
@@ -104,6 +496,29 @@ callsites@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/callsites/-/callsites-0.2.0.tgz#afab96262910a7f33c19a5775825c69f34e350ca"
+callsites@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/callsites/-/callsites-2.0.0.tgz#06eb84f00eea413da86affefacbffb36093b3c50"
+
+camelcase@^1.0.2:
+ version "1.2.1"
+ resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39"
+
+camelcase@^4.1.0:
+ version "4.1.0"
+ resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd"
+
+caseless@~0.12.0:
+ version "0.12.0"
+ resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"
+
+center-align@^0.1.1:
+ version "0.1.3"
+ resolved "https://registry.yarnpkg.com/center-align/-/center-align-0.1.3.tgz#aa0d32629b6ee972200411cbd4461c907bc2b7ad"
+ dependencies:
+ align-text "^0.1.3"
+ lazy-cache "^1.0.3"
+
chalk@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98"
@@ -114,7 +529,7 @@ chalk@^1.1.3:
strip-ansi "^3.0.0"
supports-color "^2.0.0"
-chalk@^2.0.0, chalk@^2.1.0:
+chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0:
version "2.3.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.2.tgz#250dc96b07491bfd601e648d66ddf5f60c7a5c65"
dependencies:
@@ -126,10 +541,23 @@ chardet@^0.4.0:
version "0.4.2"
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2"
+ci-info@^1.0.0:
+ version "1.1.3"
+ resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.1.3.tgz#710193264bb05c77b8c90d02f5aaf22216a667b2"
+
circular-json@^0.3.1:
version "0.3.3"
resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.3.tgz#815c99ea84f6809529d2f45791bdf82711352d66"
+class-utils@^0.3.5:
+ version "0.3.6"
+ resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463"
+ dependencies:
+ arr-union "^3.1.0"
+ define-property "^0.2.5"
+ isobject "^3.0.0"
+ static-extend "^0.1.1"
+
cli-cursor@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5"
@@ -140,10 +568,37 @@ cli-width@^2.0.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639"
+cliui@^2.1.0:
+ version "2.1.0"
+ resolved "https://registry.yarnpkg.com/cliui/-/cliui-2.1.0.tgz#4b475760ff80264c762c3a1719032e91c7fea0d1"
+ dependencies:
+ center-align "^0.1.1"
+ right-align "^0.1.1"
+ wordwrap "0.0.2"
+
+cliui@^4.0.0:
+ version "4.0.0"
+ resolved "https://registry.yarnpkg.com/cliui/-/cliui-4.0.0.tgz#743d4650e05f36d1ed2575b59638d87322bfbbcc"
+ dependencies:
+ string-width "^2.1.1"
+ strip-ansi "^4.0.0"
+ wrap-ansi "^2.0.0"
+
co@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184"
+code-point-at@^1.0.0:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
+
+collection-visit@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/collection-visit/-/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0"
+ dependencies:
+ map-visit "^1.0.0"
+ object-visit "^1.0.0"
+
color-convert@^1.9.0:
version "1.9.1"
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.1.tgz#c1261107aeb2f294ebffec9ed9ecad529a6097ed"
@@ -154,6 +609,20 @@ color-name@^1.1.1:
version "1.1.3"
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"
+combined-stream@1.0.6, combined-stream@^1.0.5, combined-stream@~1.0.5:
+ version "1.0.6"
+ resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.6.tgz#723e7df6e801ac5613113a7e445a9b69cb632818"
+ dependencies:
+ delayed-stream "~1.0.0"
+
+compare-versions@^3.1.0:
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/compare-versions/-/compare-versions-3.1.0.tgz#43310256a5c555aaed4193c04d8f154cf9c6efd5"
+
+component-emitter@^1.2.1:
+ version "1.2.1"
+ resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6"
+
concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
@@ -167,11 +636,27 @@ concat-stream@^1.6.0:
readable-stream "^2.2.2"
typedarray "^0.0.6"
-core-util-is@~1.0.0:
+console-control-strings@^1.0.0, console-control-strings@~1.1.0:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e"
+
+convert-source-map@^1.4.0, convert-source-map@^1.5.0:
+ version "1.5.1"
+ resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.5.1.tgz#b8278097b9bc229365de5c62cf5fcaed8b5599e5"
+
+copy-descriptor@^0.1.0:
+ version "0.1.1"
+ resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d"
+
+core-js@^2.4.0, core-js@^2.5.0:
+ version "2.5.4"
+ resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.4.tgz#f2c8bf181f2a80b92f360121429ce63a2f0aeae0"
+
+core-util-is@1.0.2, core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
-cross-spawn@^5.1.0:
+cross-spawn@^5.0.1, cross-spawn@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
dependencies:
@@ -179,12 +664,62 @@ cross-spawn@^5.1.0:
shebang-command "^1.2.0"
which "^1.2.9"
+cryptiles@2.x.x:
+ version "2.0.5"
+ resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8"
+ dependencies:
+ boom "2.x.x"
+
+cryptiles@3.x.x:
+ version "3.1.2"
+ resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-3.1.2.tgz#a89fbb220f5ce25ec56e8c4aa8a4fd7b5b0d29fe"
+ dependencies:
+ boom "5.x.x"
+
+cssom@0.3.x, "cssom@>= 0.3.2 < 0.4.0":
+ version "0.3.2"
+ resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.3.2.tgz#b8036170c79f07a90ff2f16e22284027a243848b"
+
+"cssstyle@>= 0.2.37 < 0.3.0":
+ version "0.2.37"
+ resolved "https://registry.yarnpkg.com/cssstyle/-/cssstyle-0.2.37.tgz#541097234cb2513c83ceed3acddc27ff27987d54"
+ dependencies:
+ cssom "0.3.x"
+
+dashdash@^1.12.0:
+ version "1.14.1"
+ resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0"
+ dependencies:
+ assert-plus "^1.0.0"
+
+data-urls@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/data-urls/-/data-urls-1.0.0.tgz#24802de4e81c298ea8a9388bb0d8e461c774684f"
+ dependencies:
+ abab "^1.0.4"
+ whatwg-mimetype "^2.0.0"
+ whatwg-url "^6.4.0"
+
+debug@^2.2.0, debug@^2.3.3, debug@^2.6.8:
+ version "2.6.9"
+ resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
+ dependencies:
+ ms "2.0.0"
+
debug@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
dependencies:
ms "2.0.0"
+decamelize@^1.0.0, decamelize@^1.1.1:
+ version "1.2.0"
+ resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
+
+decode-uri-component@^0.2.0:
+ version "0.2.0"
+ resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545"
+
deep-equal@~0.1.0:
version "0.1.2"
resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-0.1.2.tgz#b246c2b80a570a47c11be1d9bd1070ec878b87ce"
@@ -193,10 +728,20 @@ deep-equal@~1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5"
+deep-extend@~0.4.0:
+ version "0.4.2"
+ resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f"
+
deep-is@~0.1.3:
version "0.1.3"
resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34"
+default-require-extensions@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/default-require-extensions/-/default-require-extensions-1.0.0.tgz#f37ea15d3e13ffd9b437d33e1a75b5fb97874cb8"
+ dependencies:
+ strip-bom "^2.0.0"
+
define-properties@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94"
@@ -204,6 +749,25 @@ define-properties@^1.1.2:
foreach "^2.0.5"
object-keys "^1.0.8"
+define-property@^0.2.5:
+ version "0.2.5"
+ resolved "https://registry.yarnpkg.com/define-property/-/define-property-0.2.5.tgz#c35b1ef918ec3c990f9a5bc57be04aacec5c8116"
+ dependencies:
+ is-descriptor "^0.1.0"
+
+define-property@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/define-property/-/define-property-1.0.0.tgz#769ebaaf3f4a63aad3af9e8d304c9bbe79bfb0e6"
+ dependencies:
+ is-descriptor "^1.0.0"
+
+define-property@^2.0.2:
+ version "2.0.2"
+ resolved "https://registry.yarnpkg.com/define-property/-/define-property-2.0.2.tgz#d459689e8d654ba77e02a817f8710d702cb16e9d"
+ dependencies:
+ is-descriptor "^1.0.2"
+ isobject "^3.0.1"
+
defined@0.0.0, defined@~0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/defined/-/defined-0.0.0.tgz#f35eea7d705e933baf13b2f03b3f83d921403b3e"
@@ -224,17 +788,61 @@ del@^2.0.2:
pinkie-promise "^2.0.0"
rimraf "^2.2.8"
+delayed-stream@~1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
+
+delegates@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a"
+
+detect-indent@^4.0.0:
+ version "4.0.0"
+ resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-4.0.0.tgz#f76d064352cdf43a1cb6ce619c4ee3a9475de208"
+ dependencies:
+ repeating "^2.0.0"
+
+detect-libc@^1.0.2:
+ version "1.0.3"
+ resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b"
+
+detect-newline@^2.1.0:
+ version "2.1.0"
+ resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-2.1.0.tgz#f41f1c10be4b00e87b5f13da680759f2c5bfd3e2"
+
+diff@^3.2.0:
+ version "3.5.0"
+ resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12"
+
doctrine@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d"
dependencies:
esutils "^2.0.2"
+domexception@^1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/domexception/-/domexception-1.0.1.tgz#937442644ca6a31261ef36e3ec677fe805582c90"
+ dependencies:
+ webidl-conversions "^4.0.2"
+
duplexer@~0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1"
-es-abstract@^1.5.0:
+ecc-jsbn@~0.1.1:
+ version "0.1.1"
+ resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505"
+ dependencies:
+ jsbn "~0.1.0"
+
+error-ex@^1.2.0:
+ version "1.3.1"
+ resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.1.tgz#f855a86ce61adc4e8621c3cda21e7a7612c3a8dc"
+ dependencies:
+ is-arrayish "^0.2.1"
+
+es-abstract@^1.5.0, es-abstract@^1.5.1:
version "1.11.0"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.11.0.tgz#cce87d518f0496893b1a30cd8461835535480681"
dependencies:
@@ -256,6 +864,17 @@ escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
+escodegen@^1.9.0:
+ version "1.9.1"
+ resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.9.1.tgz#dbae17ef96c8e4bedb1356f4504fa4cc2f7cb7e2"
+ dependencies:
+ esprima "^3.1.3"
+ estraverse "^4.2.0"
+ esutils "^2.0.2"
+ optionator "^0.8.1"
+ optionalDependencies:
+ source-map "~0.6.1"
+
eslint-scope@^3.7.1:
version "3.7.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8"
@@ -317,6 +936,10 @@ espree@^3.5.4:
acorn "^5.5.0"
acorn-jsx "^3.0.0"
+esprima@^3.1.3:
+ version "3.1.3"
+ resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633"
+
esprima@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.0.tgz#4499eddcd1110e0b218bacf2fa7f7f59f55ca804"
@@ -333,7 +956,7 @@ esrecurse@^4.1.0:
dependencies:
estraverse "^4.1.0"
-estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1:
+estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1, estraverse@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13"
@@ -341,6 +964,80 @@ esutils@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b"
+exec-sh@^0.2.0:
+ version "0.2.1"
+ resolved "https://registry.yarnpkg.com/exec-sh/-/exec-sh-0.2.1.tgz#163b98a6e89e6b65b47c2a28d215bc1f63989c38"
+ dependencies:
+ merge "^1.1.3"
+
+execa@^0.7.0:
+ version "0.7.0"
+ resolved "https://registry.yarnpkg.com/execa/-/execa-0.7.0.tgz#944becd34cc41ee32a63a9faf27ad5a65fc59777"
+ dependencies:
+ cross-spawn "^5.0.1"
+ get-stream "^3.0.0"
+ is-stream "^1.1.0"
+ npm-run-path "^2.0.0"
+ p-finally "^1.0.0"
+ signal-exit "^3.0.0"
+ strip-eof "^1.0.0"
+
+exit@^0.1.2:
+ version "0.1.2"
+ resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c"
+
+expand-brackets@^0.1.4:
+ version "0.1.5"
+ resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b"
+ dependencies:
+ is-posix-bracket "^0.1.0"
+
+expand-brackets@^2.1.4:
+ version "2.1.4"
+ resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622"
+ dependencies:
+ debug "^2.3.3"
+ define-property "^0.2.5"
+ extend-shallow "^2.0.1"
+ posix-character-classes "^0.1.0"
+ regex-not "^1.0.0"
+ snapdragon "^0.8.1"
+ to-regex "^3.0.1"
+
+expand-range@^1.8.1:
+ version "1.8.2"
+ resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-1.8.2.tgz#a299effd335fe2721ebae8e257ec79644fc85337"
+ dependencies:
+ fill-range "^2.1.0"
+
+expect@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/expect/-/expect-22.4.3.tgz#d5a29d0a0e1fb2153557caef2674d4547e914674"
+ dependencies:
+ ansi-styles "^3.2.0"
+ jest-diff "^22.4.3"
+ jest-get-type "^22.4.3"
+ jest-matcher-utils "^22.4.3"
+ jest-message-util "^22.4.3"
+ jest-regex-util "^22.4.3"
+
+extend-shallow@^2.0.1:
+ version "2.0.1"
+ resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f"
+ dependencies:
+ is-extendable "^0.1.0"
+
+extend-shallow@^3.0.0, extend-shallow@^3.0.2:
+ version "3.0.2"
+ resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-3.0.2.tgz#26a71aaf073b39fb2127172746131c2704028db8"
+ dependencies:
+ assign-symbols "^1.0.0"
+ is-extendable "^1.0.1"
+
+extend@~3.0.0, extend@~3.0.1:
+ version "3.0.1"
+ resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444"
+
external-editor@^2.0.4:
version "2.2.0"
resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.2.0.tgz#045511cfd8d133f3846673d1047c154e214ad3d5"
@@ -349,6 +1046,33 @@ external-editor@^2.0.4:
iconv-lite "^0.4.17"
tmp "^0.0.33"
+extglob@^0.3.1:
+ version "0.3.2"
+ resolved "https://registry.yarnpkg.com/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1"
+ dependencies:
+ is-extglob "^1.0.0"
+
+extglob@^2.0.4:
+ version "2.0.4"
+ resolved "https://registry.yarnpkg.com/extglob/-/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543"
+ dependencies:
+ array-unique "^0.3.2"
+ define-property "^1.0.0"
+ expand-brackets "^2.1.4"
+ extend-shallow "^2.0.1"
+ fragment-cache "^0.2.1"
+ regex-not "^1.0.0"
+ snapdragon "^0.8.1"
+ to-regex "^3.0.1"
+
+extsprintf@1.3.0:
+ version "1.3.0"
+ resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05"
+
+extsprintf@^1.2.0:
+ version "1.4.0"
+ resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f"
+
fast-deep-equal@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz#c053477817c86b51daa853c81e059b733d023614"
@@ -373,6 +1097,12 @@ faucet@^0.0.1:
tape "~2.3.2"
through2 "~0.2.3"
+fb-watchman@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.0.tgz#54e9abf7dfa2f26cd9b1636c588c1afc05de5d58"
+ dependencies:
+ bser "^2.0.0"
+
figures@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962"
@@ -386,6 +1116,49 @@ file-entry-cache@^2.0.0:
flat-cache "^1.2.1"
object-assign "^4.0.1"
+filename-regex@^2.0.0:
+ version "2.0.1"
+ resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26"
+
+fileset@^2.0.2:
+ version "2.0.3"
+ resolved "https://registry.yarnpkg.com/fileset/-/fileset-2.0.3.tgz#8e7548a96d3cc2327ee5e674168723a333bba2a0"
+ dependencies:
+ glob "^7.0.3"
+ minimatch "^3.0.3"
+
+fill-range@^2.1.0:
+ version "2.2.3"
+ resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-2.2.3.tgz#50b77dfd7e469bc7492470963699fe7a8485a723"
+ dependencies:
+ is-number "^2.1.0"
+ isobject "^2.0.0"
+ randomatic "^1.1.3"
+ repeat-element "^1.1.2"
+ repeat-string "^1.5.2"
+
+fill-range@^4.0.0:
+ version "4.0.0"
+ resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7"
+ dependencies:
+ extend-shallow "^2.0.1"
+ is-number "^3.0.0"
+ repeat-string "^1.6.1"
+ to-regex-range "^2.1.0"
+
+find-up@^1.0.0:
+ version "1.1.2"
+ resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f"
+ dependencies:
+ path-exists "^2.0.0"
+ pinkie-promise "^2.0.0"
+
+find-up@^2.1.0:
+ version "2.1.0"
+ resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7"
+ dependencies:
+ locate-path "^2.0.0"
+
flat-cache@^1.2.1:
version "1.3.0"
resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.3.0.tgz#d3030b32b38154f4e3b7e9c709f490f7ef97c481"
@@ -401,14 +1174,74 @@ for-each@~0.3.2:
dependencies:
is-function "~1.0.0"
+for-in@^1.0.1, for-in@^1.0.2:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
+
+for-own@^0.1.4:
+ version "0.1.5"
+ resolved "https://registry.yarnpkg.com/for-own/-/for-own-0.1.5.tgz#5265c681a4f294dabbf17c9509b6763aa84510ce"
+ dependencies:
+ for-in "^1.0.1"
+
foreach@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"
+forever-agent@~0.6.1:
+ version "0.6.1"
+ resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91"
+
+form-data@~2.1.1:
+ version "2.1.4"
+ resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.4.tgz#33c183acf193276ecaa98143a69e94bfee1750d1"
+ dependencies:
+ asynckit "^0.4.0"
+ combined-stream "^1.0.5"
+ mime-types "^2.1.12"
+
+form-data@~2.3.1:
+ version "2.3.2"
+ resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.2.tgz#4970498be604c20c005d4f5c23aecd21d6b49099"
+ dependencies:
+ asynckit "^0.4.0"
+ combined-stream "1.0.6"
+ mime-types "^2.1.12"
+
+fragment-cache@^0.2.1:
+ version "0.2.1"
+ resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19"
+ dependencies:
+ map-cache "^0.2.2"
+
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
+fsevents@^1.1.1:
+ version "1.1.3"
+ resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.1.3.tgz#11f82318f5fe7bb2cd22965a108e9306208216d8"
+ dependencies:
+ nan "^2.3.0"
+ node-pre-gyp "^0.6.39"
+
+fstream-ignore@^1.0.5:
+ version "1.0.5"
+ resolved "https://registry.yarnpkg.com/fstream-ignore/-/fstream-ignore-1.0.5.tgz#9c31dae34767018fe1d249b24dada67d092da105"
+ dependencies:
+ fstream "^1.0.0"
+ inherits "2"
+ minimatch "^3.0.0"
+
+fstream@^1.0.0, fstream@^1.0.10, fstream@^1.0.2:
+ version "1.0.11"
+ resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.11.tgz#5c1fb1f117477114f0632a0eb4b71b3cb0fd3171"
+ dependencies:
+ graceful-fs "^4.1.2"
+ inherits "~2.0.0"
+ mkdirp ">=0.5 0"
+ rimraf "2"
+
function-bind@^1.0.2, function-bind@^1.1.1, function-bind@~1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
@@ -417,7 +1250,51 @@ functional-red-black-tree@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327"
-glob@^7.0.3, glob@^7.0.5, glob@^7.1.2, glob@~7.1.2:
+gauge@~2.7.3:
+ version "2.7.4"
+ resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7"
+ dependencies:
+ aproba "^1.0.3"
+ console-control-strings "^1.0.0"
+ has-unicode "^2.0.0"
+ object-assign "^4.1.0"
+ signal-exit "^3.0.0"
+ string-width "^1.0.1"
+ strip-ansi "^3.0.1"
+ wide-align "^1.1.0"
+
+get-caller-file@^1.0.1:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.2.tgz#f702e63127e7e231c160a80c1554acb70d5047e5"
+
+get-stream@^3.0.0:
+ version "3.0.0"
+ resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14"
+
+get-value@^2.0.3, get-value@^2.0.6:
+ version "2.0.6"
+ resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28"
+
+getpass@^0.1.1:
+ version "0.1.7"
+ resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa"
+ dependencies:
+ assert-plus "^1.0.0"
+
+glob-base@^0.3.0:
+ version "0.3.0"
+ resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4"
+ dependencies:
+ glob-parent "^2.0.0"
+ is-glob "^2.0.0"
+
+glob-parent@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-2.0.0.tgz#81383d72db054fcccf5336daa902f182f6edbb28"
+ dependencies:
+ is-glob "^2.0.0"
+
+glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2, glob@~7.1.2:
version "7.1.2"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
dependencies:
@@ -432,6 +1309,10 @@ globals@^11.0.1:
version "11.4.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-11.4.0.tgz#b85c793349561c16076a3c13549238a27945f1bc"
+globals@^9.18.0:
+ version "9.18.0"
+ resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a"
+
globby@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/globby/-/globby-5.0.0.tgz#ebd84667ca0dbb330b99bcfc68eac2bc54370e0d"
@@ -443,27 +1324,157 @@ globby@^5.0.0:
pify "^2.0.0"
pinkie-promise "^2.0.0"
-graceful-fs@^4.1.2:
+graceful-fs@^4.1.11, graceful-fs@^4.1.2:
version "4.1.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
+growly@^1.3.0:
+ version "1.3.0"
+ resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081"
+
+handlebars@^4.0.3:
+ version "4.0.11"
+ resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.11.tgz#630a35dfe0294bc281edae6ffc5d329fc7982dcc"
+ dependencies:
+ async "^1.4.0"
+ optimist "^0.6.1"
+ source-map "^0.4.4"
+ optionalDependencies:
+ uglify-js "^2.6"
+
+har-schema@^1.0.5:
+ version "1.0.5"
+ resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-1.0.5.tgz#d263135f43307c02c602afc8fe95970c0151369e"
+
+har-schema@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92"
+
+har-validator@~4.2.1:
+ version "4.2.1"
+ resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-4.2.1.tgz#33481d0f1bbff600dd203d75812a6a5fba002e2a"
+ dependencies:
+ ajv "^4.9.1"
+ har-schema "^1.0.5"
+
+har-validator@~5.0.3:
+ version "5.0.3"
+ resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.0.3.tgz#ba402c266194f15956ef15e0fcf242993f6a7dfd"
+ dependencies:
+ ajv "^5.1.0"
+ har-schema "^2.0.0"
+
has-ansi@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91"
dependencies:
ansi-regex "^2.0.0"
+has-flag@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa"
+
has-flag@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"
+has-unicode@^2.0.0:
+ version "2.0.1"
+ resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9"
+
+has-value@^0.3.1:
+ version "0.3.1"
+ resolved "https://registry.yarnpkg.com/has-value/-/has-value-0.3.1.tgz#7b1f58bada62ca827ec0a2078025654845995e1f"
+ dependencies:
+ get-value "^2.0.3"
+ has-values "^0.1.4"
+ isobject "^2.0.0"
+
+has-value@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/has-value/-/has-value-1.0.0.tgz#18b281da585b1c5c51def24c930ed29a0be6b177"
+ dependencies:
+ get-value "^2.0.6"
+ has-values "^1.0.0"
+ isobject "^3.0.0"
+
+has-values@^0.1.4:
+ version "0.1.4"
+ resolved "https://registry.yarnpkg.com/has-values/-/has-values-0.1.4.tgz#6d61de95d91dfca9b9a02089ad384bff8f62b771"
+
+has-values@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/has-values/-/has-values-1.0.0.tgz#95b0b63fec2146619a6fe57fe75628d5a39efe4f"
+ dependencies:
+ is-number "^3.0.0"
+ kind-of "^4.0.0"
+
has@^1.0.1, has@~1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28"
dependencies:
function-bind "^1.0.2"
-iconv-lite@^0.4.17:
+hawk@3.1.3, hawk@~3.1.3:
+ version "3.1.3"
+ resolved "https://registry.yarnpkg.com/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4"
+ dependencies:
+ boom "2.x.x"
+ cryptiles "2.x.x"
+ hoek "2.x.x"
+ sntp "1.x.x"
+
+hawk@~6.0.2:
+ version "6.0.2"
+ resolved "https://registry.yarnpkg.com/hawk/-/hawk-6.0.2.tgz#af4d914eb065f9b5ce4d9d11c1cb2126eecc3038"
+ dependencies:
+ boom "4.x.x"
+ cryptiles "3.x.x"
+ hoek "4.x.x"
+ sntp "2.x.x"
+
+hoek@2.x.x:
+ version "2.16.3"
+ resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed"
+
+hoek@4.x.x:
+ version "4.2.1"
+ resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.1.tgz#9634502aa12c445dd5a7c5734b572bb8738aacbb"
+
+home-or-tmp@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8"
+ dependencies:
+ os-homedir "^1.0.0"
+ os-tmpdir "^1.0.1"
+
+hosted-git-info@^2.1.4:
+ version "2.6.0"
+ resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.6.0.tgz#23235b29ab230c576aab0d4f13fc046b0b038222"
+
+html-encoding-sniffer@^1.0.2:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz#e70d84b94da53aa375e11fe3a351be6642ca46f8"
+ dependencies:
+ whatwg-encoding "^1.0.1"
+
+http-signature@~1.1.0:
+ version "1.1.1"
+ resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.1.1.tgz#df72e267066cd0ac67fb76adf8e134a8fbcf91bf"
+ dependencies:
+ assert-plus "^0.2.0"
+ jsprim "^1.2.2"
+ sshpk "^1.7.0"
+
+http-signature@~1.2.0:
+ version "1.2.0"
+ resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1"
+ dependencies:
+ assert-plus "^1.0.0"
+ jsprim "^1.2.2"
+ sshpk "^1.7.0"
+
+iconv-lite@0.4.19, iconv-lite@^0.4.17:
version "0.4.19"
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b"
@@ -471,6 +1482,13 @@ ignore@^3.3.3:
version "3.3.7"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.7.tgz#612289bfb3c220e186a58118618d5be8c1bab021"
+import-local@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/import-local/-/import-local-1.0.0.tgz#5e4ffdc03f4fe6c009c6729beb29631c2f8227bc"
+ dependencies:
+ pkg-dir "^2.0.0"
+ resolve-cwd "^2.0.0"
+
imurmurhash@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
@@ -482,10 +1500,14 @@ inflight@^1.0.4:
once "^1.3.0"
wrappy "1"
-inherits@2, inherits@^2.0.3, inherits@~2.0.1, inherits@~2.0.3:
+inherits@2, inherits@^2.0.3, inherits@~2.0.0, inherits@~2.0.1, inherits@~2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
+ini@~1.3.0:
+ version "1.3.5"
+ resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927"
+
inquirer@^3.0.6:
version "3.3.0"
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-3.3.0.tgz#9dd2f2ad765dcab1ff0443b491442a20ba227dc9"
@@ -505,14 +1527,120 @@ inquirer@^3.0.6:
strip-ansi "^4.0.0"
through "^2.3.6"
+invariant@^2.2.2:
+ version "2.2.4"
+ resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6"
+ dependencies:
+ loose-envify "^1.0.0"
+
+invert-kv@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6"
+
+is-accessor-descriptor@^0.1.6:
+ version "0.1.6"
+ resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6"
+ dependencies:
+ kind-of "^3.0.2"
+
+is-accessor-descriptor@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz#169c2f6d3df1f992618072365c9b0ea1f6878656"
+ dependencies:
+ kind-of "^6.0.0"
+
+is-arrayish@^0.2.1:
+ version "0.2.1"
+ resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d"
+
+is-buffer@^1.1.5:
+ version "1.1.6"
+ resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be"
+
+is-builtin-module@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/is-builtin-module/-/is-builtin-module-1.0.0.tgz#540572d34f7ac3119f8f76c30cbc1b1e037affbe"
+ dependencies:
+ builtin-modules "^1.0.0"
+
is-callable@^1.1.1, is-callable@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2"
+is-ci@^1.0.10:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-1.1.0.tgz#247e4162e7860cebbdaf30b774d6b0ac7dcfe7a5"
+ dependencies:
+ ci-info "^1.0.0"
+
+is-data-descriptor@^0.1.4:
+ version "0.1.4"
+ resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56"
+ dependencies:
+ kind-of "^3.0.2"
+
+is-data-descriptor@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz#d84876321d0e7add03990406abbbbd36ba9268c7"
+ dependencies:
+ kind-of "^6.0.0"
+
is-date-object@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16"
+is-descriptor@^0.1.0:
+ version "0.1.6"
+ resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-0.1.6.tgz#366d8240dde487ca51823b1ab9f07a10a78251ca"
+ dependencies:
+ is-accessor-descriptor "^0.1.6"
+ is-data-descriptor "^0.1.4"
+ kind-of "^5.0.0"
+
+is-descriptor@^1.0.0, is-descriptor@^1.0.2:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-1.0.2.tgz#3b159746a66604b04f8c81524ba365c5f14d86ec"
+ dependencies:
+ is-accessor-descriptor "^1.0.0"
+ is-data-descriptor "^1.0.0"
+ kind-of "^6.0.2"
+
+is-dotfile@^1.0.0:
+ version "1.0.3"
+ resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.3.tgz#a6a2f32ffd2dfb04f5ca25ecd0f6b83cf798a1e1"
+
+is-equal-shallow@^0.1.3:
+ version "0.1.3"
+ resolved "https://registry.yarnpkg.com/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz#2238098fc221de0bcfa5d9eac4c45d638aa1c534"
+ dependencies:
+ is-primitive "^2.0.0"
+
+is-extendable@^0.1.0, is-extendable@^0.1.1:
+ version "0.1.1"
+ resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89"
+
+is-extendable@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-1.0.1.tgz#a7470f9e426733d81bd81e1155264e3a3507cab4"
+ dependencies:
+ is-plain-object "^2.0.4"
+
+is-extglob@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0"
+
+is-finite@^1.0.0:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa"
+ dependencies:
+ number-is-nan "^1.0.0"
+
+is-fullwidth-code-point@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb"
+ dependencies:
+ number-is-nan "^1.0.0"
+
is-fullwidth-code-point@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f"
@@ -521,6 +1649,38 @@ is-function@~1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-function/-/is-function-1.0.1.tgz#12cfb98b65b57dd3d193a3121f5f6e2f437602b5"
+is-generator-fn@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/is-generator-fn/-/is-generator-fn-1.0.0.tgz#969d49e1bb3329f6bb7f09089be26578b2ddd46a"
+
+is-glob@^2.0.0, is-glob@^2.0.1:
+ version "2.0.1"
+ resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863"
+ dependencies:
+ is-extglob "^1.0.0"
+
+is-number@^2.1.0:
+ version "2.1.0"
+ resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f"
+ dependencies:
+ kind-of "^3.0.2"
+
+is-number@^3.0.0:
+ version "3.0.0"
+ resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195"
+ dependencies:
+ kind-of "^3.0.2"
+
+is-number@^4.0.0:
+ version "4.0.0"
+ resolved "https://registry.yarnpkg.com/is-number/-/is-number-4.0.0.tgz#0026e37f5454d73e356dfe6564699867c6a7f0ff"
+
+is-odd@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/is-odd/-/is-odd-2.0.0.tgz#7646624671fd7ea558ccd9a2795182f2958f1b24"
+ dependencies:
+ is-number "^4.0.0"
+
is-path-cwd@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-1.0.0.tgz#d225ec23132e89edd38fda767472e62e65f1106d"
@@ -537,6 +1697,20 @@ is-path-inside@^1.0.0:
dependencies:
path-is-inside "^1.0.1"
+is-plain-object@^2.0.1, is-plain-object@^2.0.3, is-plain-object@^2.0.4:
+ version "2.0.4"
+ resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677"
+ dependencies:
+ isobject "^3.0.1"
+
+is-posix-bracket@^0.1.0:
+ version "0.1.1"
+ resolved "https://registry.yarnpkg.com/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4"
+
+is-primitive@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575"
+
is-promise@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa"
@@ -551,15 +1725,31 @@ is-resolvable@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.1.0.tgz#fb18f87ce1feb925169c9a407c19318a3206ed88"
+is-stream@^1.1.0:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
+
is-symbol@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572"
+is-typedarray@~1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"
+
+is-utf8@^0.2.0:
+ version "0.2.1"
+ resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72"
+
+is-windows@^1.0.2:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"
+
isarray@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf"
-isarray@~1.0.0:
+isarray@1.0.0, isarray@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
@@ -567,29 +1757,480 @@ isexe@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
-js-tokens@^3.0.2:
+isobject@^2.0.0:
+ version "2.1.0"
+ resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89"
+ dependencies:
+ isarray "1.0.0"
+
+isobject@^3.0.0, isobject@^3.0.1:
+ version "3.0.1"
+ resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
+
+isstream@~0.1.2:
+ version "0.1.2"
+ resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a"
+
+istanbul-api@^1.1.14:
+ version "1.3.1"
+ resolved "https://registry.yarnpkg.com/istanbul-api/-/istanbul-api-1.3.1.tgz#4c3b05d18c0016d1022e079b98dc82c40f488954"
+ dependencies:
+ async "^2.1.4"
+ compare-versions "^3.1.0"
+ fileset "^2.0.2"
+ istanbul-lib-coverage "^1.2.0"
+ istanbul-lib-hook "^1.2.0"
+ istanbul-lib-instrument "^1.10.1"
+ istanbul-lib-report "^1.1.4"
+ istanbul-lib-source-maps "^1.2.4"
+ istanbul-reports "^1.3.0"
+ js-yaml "^3.7.0"
+ mkdirp "^0.5.1"
+ once "^1.4.0"
+
+istanbul-lib-coverage@^1.1.1, istanbul-lib-coverage@^1.1.2, istanbul-lib-coverage@^1.2.0:
+ version "1.2.0"
+ resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.2.0.tgz#f7d8f2e42b97e37fe796114cb0f9d68b5e3a4341"
+
+istanbul-lib-hook@^1.2.0:
+ version "1.2.0"
+ resolved "https://registry.yarnpkg.com/istanbul-lib-hook/-/istanbul-lib-hook-1.2.0.tgz#ae556fd5a41a6e8efa0b1002b1e416dfeaf9816c"
+ dependencies:
+ append-transform "^0.4.0"
+
+istanbul-lib-instrument@^1.10.1, istanbul-lib-instrument@^1.7.5, istanbul-lib-instrument@^1.8.0:
+ version "1.10.1"
+ resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.10.1.tgz#724b4b6caceba8692d3f1f9d0727e279c401af7b"
+ dependencies:
+ babel-generator "^6.18.0"
+ babel-template "^6.16.0"
+ babel-traverse "^6.18.0"
+ babel-types "^6.18.0"
+ babylon "^6.18.0"
+ istanbul-lib-coverage "^1.2.0"
+ semver "^5.3.0"
+
+istanbul-lib-report@^1.1.4:
+ version "1.1.4"
+ resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-1.1.4.tgz#e886cdf505c4ebbd8e099e4396a90d0a28e2acb5"
+ dependencies:
+ istanbul-lib-coverage "^1.2.0"
+ mkdirp "^0.5.1"
+ path-parse "^1.0.5"
+ supports-color "^3.1.2"
+
+istanbul-lib-source-maps@^1.2.1:
+ version "1.2.3"
+ resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-1.2.3.tgz#20fb54b14e14b3fb6edb6aca3571fd2143db44e6"
+ dependencies:
+ debug "^3.1.0"
+ istanbul-lib-coverage "^1.1.2"
+ mkdirp "^0.5.1"
+ rimraf "^2.6.1"
+ source-map "^0.5.3"
+
+istanbul-lib-source-maps@^1.2.4:
+ version "1.2.4"
+ resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-1.2.4.tgz#cc7ccad61629f4efff8e2f78adb8c522c9976ec7"
+ dependencies:
+ debug "^3.1.0"
+ istanbul-lib-coverage "^1.2.0"
+ mkdirp "^0.5.1"
+ rimraf "^2.6.1"
+ source-map "^0.5.3"
+
+istanbul-reports@^1.3.0:
+ version "1.3.0"
+ resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-1.3.0.tgz#2f322e81e1d9520767597dca3c20a0cce89a3554"
+ dependencies:
+ handlebars "^4.0.3"
+
+jest-changed-files@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-22.4.3.tgz#8882181e022c38bd46a2e4d18d44d19d90a90fb2"
+ dependencies:
+ throat "^4.0.0"
+
+jest-cli@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-22.4.3.tgz#bf16c4a5fb7edc3fa5b9bb7819e34139e88a72c7"
+ dependencies:
+ ansi-escapes "^3.0.0"
+ chalk "^2.0.1"
+ exit "^0.1.2"
+ glob "^7.1.2"
+ graceful-fs "^4.1.11"
+ import-local "^1.0.0"
+ is-ci "^1.0.10"
+ istanbul-api "^1.1.14"
+ istanbul-lib-coverage "^1.1.1"
+ istanbul-lib-instrument "^1.8.0"
+ istanbul-lib-source-maps "^1.2.1"
+ jest-changed-files "^22.4.3"
+ jest-config "^22.4.3"
+ jest-environment-jsdom "^22.4.3"
+ jest-get-type "^22.4.3"
+ jest-haste-map "^22.4.3"
+ jest-message-util "^22.4.3"
+ jest-regex-util "^22.4.3"
+ jest-resolve-dependencies "^22.4.3"
+ jest-runner "^22.4.3"
+ jest-runtime "^22.4.3"
+ jest-snapshot "^22.4.3"
+ jest-util "^22.4.3"
+ jest-validate "^22.4.3"
+ jest-worker "^22.4.3"
+ micromatch "^2.3.11"
+ node-notifier "^5.2.1"
+ realpath-native "^1.0.0"
+ rimraf "^2.5.4"
+ slash "^1.0.0"
+ string-length "^2.0.0"
+ strip-ansi "^4.0.0"
+ which "^1.2.12"
+ yargs "^10.0.3"
+
+jest-config@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-22.4.3.tgz#0e9d57db267839ea31309119b41dc2fa31b76403"
+ dependencies:
+ chalk "^2.0.1"
+ glob "^7.1.1"
+ jest-environment-jsdom "^22.4.3"
+ jest-environment-node "^22.4.3"
+ jest-get-type "^22.4.3"
+ jest-jasmine2 "^22.4.3"
+ jest-regex-util "^22.4.3"
+ jest-resolve "^22.4.3"
+ jest-util "^22.4.3"
+ jest-validate "^22.4.3"
+ pretty-format "^22.4.3"
+
+jest-diff@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-22.4.3.tgz#e18cc3feff0aeef159d02310f2686d4065378030"
+ dependencies:
+ chalk "^2.0.1"
+ diff "^3.2.0"
+ jest-get-type "^22.4.3"
+ pretty-format "^22.4.3"
+
+jest-docblock@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-22.4.3.tgz#50886f132b42b280c903c592373bb6e93bb68b19"
+ dependencies:
+ detect-newline "^2.1.0"
+
+jest-environment-jsdom@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest-environment-jsdom/-/jest-environment-jsdom-22.4.3.tgz#d67daa4155e33516aecdd35afd82d4abf0fa8a1e"
+ dependencies:
+ jest-mock "^22.4.3"
+ jest-util "^22.4.3"
+ jsdom "^11.5.1"
+
+jest-environment-node@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-22.4.3.tgz#54c4eaa374c83dd52a9da8759be14ebe1d0b9129"
+ dependencies:
+ jest-mock "^22.4.3"
+ jest-util "^22.4.3"
+
+jest-get-type@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-22.4.3.tgz#e3a8504d8479342dd4420236b322869f18900ce4"
+
+jest-haste-map@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-22.4.3.tgz#25842fa2ba350200767ac27f658d58b9d5c2e20b"
+ dependencies:
+ fb-watchman "^2.0.0"
+ graceful-fs "^4.1.11"
+ jest-docblock "^22.4.3"
+ jest-serializer "^22.4.3"
+ jest-worker "^22.4.3"
+ micromatch "^2.3.11"
+ sane "^2.0.0"
+
+jest-jasmine2@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest-jasmine2/-/jest-jasmine2-22.4.3.tgz#4daf64cd14c793da9db34a7c7b8dcfe52a745965"
+ dependencies:
+ chalk "^2.0.1"
+ co "^4.6.0"
+ expect "^22.4.3"
+ graceful-fs "^4.1.11"
+ is-generator-fn "^1.0.0"
+ jest-diff "^22.4.3"
+ jest-matcher-utils "^22.4.3"
+ jest-message-util "^22.4.3"
+ jest-snapshot "^22.4.3"
+ jest-util "^22.4.3"
+ source-map-support "^0.5.0"
+
+jest-leak-detector@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-22.4.3.tgz#2b7b263103afae8c52b6b91241a2de40117e5b35"
+ dependencies:
+ pretty-format "^22.4.3"
+
+jest-matcher-utils@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-22.4.3.tgz#4632fe428ebc73ebc194d3c7b65d37b161f710ff"
+ dependencies:
+ chalk "^2.0.1"
+ jest-get-type "^22.4.3"
+ pretty-format "^22.4.3"
+
+jest-message-util@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-22.4.3.tgz#cf3d38aafe4befddbfc455e57d65d5239e399eb7"
+ dependencies:
+ "@babel/code-frame" "^7.0.0-beta.35"
+ chalk "^2.0.1"
+ micromatch "^2.3.11"
+ slash "^1.0.0"
+ stack-utils "^1.0.1"
+
+jest-mock@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-22.4.3.tgz#f63ba2f07a1511772cdc7979733397df770aabc7"
+
+jest-regex-util@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-22.4.3.tgz#a826eb191cdf22502198c5401a1fc04de9cef5af"
+
+jest-resolve-dependencies@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest-resolve-dependencies/-/jest-resolve-dependencies-22.4.3.tgz#e2256a5a846732dc3969cb72f3c9ad7725a8195e"
+ dependencies:
+ jest-regex-util "^22.4.3"
+
+jest-resolve@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-22.4.3.tgz#0ce9d438c8438229aa9b916968ec6b05c1abb4ea"
+ dependencies:
+ browser-resolve "^1.11.2"
+ chalk "^2.0.1"
+
+jest-runner@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest-runner/-/jest-runner-22.4.3.tgz#298ddd6a22b992c64401b4667702b325e50610c3"
+ dependencies:
+ exit "^0.1.2"
+ jest-config "^22.4.3"
+ jest-docblock "^22.4.3"
+ jest-haste-map "^22.4.3"
+ jest-jasmine2 "^22.4.3"
+ jest-leak-detector "^22.4.3"
+ jest-message-util "^22.4.3"
+ jest-runtime "^22.4.3"
+ jest-util "^22.4.3"
+ jest-worker "^22.4.3"
+ throat "^4.0.0"
+
+jest-runtime@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest-runtime/-/jest-runtime-22.4.3.tgz#b69926c34b851b920f666c93e86ba2912087e3d0"
+ dependencies:
+ babel-core "^6.0.0"
+ babel-jest "^22.4.3"
+ babel-plugin-istanbul "^4.1.5"
+ chalk "^2.0.1"
+ convert-source-map "^1.4.0"
+ exit "^0.1.2"
+ graceful-fs "^4.1.11"
+ jest-config "^22.4.3"
+ jest-haste-map "^22.4.3"
+ jest-regex-util "^22.4.3"
+ jest-resolve "^22.4.3"
+ jest-util "^22.4.3"
+ jest-validate "^22.4.3"
+ json-stable-stringify "^1.0.1"
+ micromatch "^2.3.11"
+ realpath-native "^1.0.0"
+ slash "^1.0.0"
+ strip-bom "3.0.0"
+ write-file-atomic "^2.1.0"
+ yargs "^10.0.3"
+
+jest-serializer@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest-serializer/-/jest-serializer-22.4.3.tgz#a679b81a7f111e4766235f4f0c46d230ee0f7436"
+
+jest-snapshot@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-22.4.3.tgz#b5c9b42846ffb9faccb76b841315ba67887362d2"
+ dependencies:
+ chalk "^2.0.1"
+ jest-diff "^22.4.3"
+ jest-matcher-utils "^22.4.3"
+ mkdirp "^0.5.1"
+ natural-compare "^1.4.0"
+ pretty-format "^22.4.3"
+
+jest-util@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-22.4.3.tgz#c70fec8eec487c37b10b0809dc064a7ecf6aafac"
+ dependencies:
+ callsites "^2.0.0"
+ chalk "^2.0.1"
+ graceful-fs "^4.1.11"
+ is-ci "^1.0.10"
+ jest-message-util "^22.4.3"
+ mkdirp "^0.5.1"
+ source-map "^0.6.0"
+
+jest-validate@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-22.4.3.tgz#0780954a5a7daaeec8d3c10834b9280865976b30"
+ dependencies:
+ chalk "^2.0.1"
+ jest-config "^22.4.3"
+ jest-get-type "^22.4.3"
+ leven "^2.1.0"
+ pretty-format "^22.4.3"
+
+jest-worker@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-22.4.3.tgz#5c421417cba1c0abf64bf56bd5fb7968d79dd40b"
+ dependencies:
+ merge-stream "^1.0.1"
+
+jest@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/jest/-/jest-22.4.3.tgz#2261f4b117dc46d9a4a1a673d2150958dee92f16"
+ dependencies:
+ import-local "^1.0.0"
+ jest-cli "^22.4.3"
+
+js-tokens@^3.0.0, js-tokens@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
-js-yaml@^3.9.1:
+js-yaml@^3.7.0, js-yaml@^3.9.1:
version "3.11.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.11.0.tgz#597c1a8bd57152f26d622ce4117851a51f5ebaef"
dependencies:
argparse "^1.0.7"
esprima "^4.0.0"
+jsbn@~0.1.0:
+ version "0.1.1"
+ resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"
+
+jsdom@^11.5.1:
+ version "11.7.0"
+ resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-11.7.0.tgz#8b45b657dae90d6d2d3a5f5d1126bb7102d0a172"
+ dependencies:
+ abab "^1.0.4"
+ acorn "^5.3.0"
+ acorn-globals "^4.1.0"
+ array-equal "^1.0.0"
+ cssom ">= 0.3.2 < 0.4.0"
+ cssstyle ">= 0.2.37 < 0.3.0"
+ data-urls "^1.0.0"
+ domexception "^1.0.0"
+ escodegen "^1.9.0"
+ html-encoding-sniffer "^1.0.2"
+ left-pad "^1.2.0"
+ nwmatcher "^1.4.3"
+ parse5 "4.0.0"
+ pn "^1.1.0"
+ request "^2.83.0"
+ request-promise-native "^1.0.5"
+ sax "^1.2.4"
+ symbol-tree "^3.2.2"
+ tough-cookie "^2.3.3"
+ w3c-hr-time "^1.0.1"
+ webidl-conversions "^4.0.2"
+ whatwg-encoding "^1.0.3"
+ whatwg-mimetype "^2.1.0"
+ whatwg-url "^6.4.0"
+ ws "^4.0.0"
+ xml-name-validator "^3.0.0"
+
+jsesc@^1.3.0:
+ version "1.3.0"
+ resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b"
+
json-schema-traverse@^0.3.0:
version "0.3.1"
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340"
+json-schema@0.2.3:
+ version "0.2.3"
+ resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13"
+
json-stable-stringify-without-jsonify@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"
+json-stable-stringify@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af"
+ dependencies:
+ jsonify "~0.0.0"
+
+json-stringify-safe@~5.0.1:
+ version "5.0.1"
+ resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
+
+json5@^0.5.1:
+ version "0.5.1"
+ resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"
+
jsonify@~0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73"
+jsprim@^1.2.2:
+ version "1.4.1"
+ resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2"
+ dependencies:
+ assert-plus "1.0.0"
+ extsprintf "1.3.0"
+ json-schema "0.2.3"
+ verror "1.10.0"
+
+kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0:
+ version "3.2.2"
+ resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64"
+ dependencies:
+ is-buffer "^1.1.5"
+
+kind-of@^4.0.0:
+ version "4.0.0"
+ resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57"
+ dependencies:
+ is-buffer "^1.1.5"
+
+kind-of@^5.0.0:
+ version "5.1.0"
+ resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d"
+
+kind-of@^6.0.0, kind-of@^6.0.2:
+ version "6.0.2"
+ resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051"
+
+lazy-cache@^1.0.3:
+ version "1.0.4"
+ resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e"
+
+lcid@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835"
+ dependencies:
+ invert-kv "^1.0.0"
+
+left-pad@^1.2.0:
+ version "1.2.0"
+ resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.2.0.tgz#d30a73c6b8201d8f7d8e7956ba9616087a68e0ee"
+
+leven@^2.1.0:
+ version "2.1.0"
+ resolved "https://registry.yarnpkg.com/leven/-/leven-2.1.0.tgz#c2e7a9f772094dee9d34202ae8acce4687875580"
+
levn@^0.3.0, levn@~0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee"
@@ -597,10 +2238,41 @@ levn@^0.3.0, levn@~0.3.0:
prelude-ls "~1.1.2"
type-check "~0.3.2"
-lodash@^4.17.4, lodash@^4.3.0:
+load-json-file@^1.0.0:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0"
+ dependencies:
+ graceful-fs "^4.1.2"
+ parse-json "^2.2.0"
+ pify "^2.0.0"
+ pinkie-promise "^2.0.0"
+ strip-bom "^2.0.0"
+
+locate-path@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e"
+ dependencies:
+ p-locate "^2.0.0"
+ path-exists "^3.0.0"
+
+lodash.sortby@^4.7.0:
+ version "4.7.0"
+ resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
+
+lodash@^4.13.1, lodash@^4.14.0, lodash@^4.17.4, lodash@^4.3.0:
version "4.17.5"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.5.tgz#99a92d65c0272debe8c96b6057bc8fbfa3bed511"
+longest@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097"
+
+loose-envify@^1.0.0:
+ version "1.3.1"
+ resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
+ dependencies:
+ js-tokens "^3.0.0"
+
lru-cache@^4.0.1:
version "4.1.2"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.2.tgz#45234b2e6e2f2b33da125624c4664929a0224c3f"
@@ -608,11 +2280,89 @@ lru-cache@^4.0.1:
pseudomap "^1.0.2"
yallist "^2.1.2"
+makeerror@1.0.x:
+ version "1.0.11"
+ resolved "https://registry.yarnpkg.com/makeerror/-/makeerror-1.0.11.tgz#e01a5c9109f2af79660e4e8b9587790184f5a96c"
+ dependencies:
+ tmpl "1.0.x"
+
+map-cache@^0.2.2:
+ version "0.2.2"
+ resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf"
+
+map-visit@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/map-visit/-/map-visit-1.0.0.tgz#ecdca8f13144e660f1b5bd41f12f3479d98dfb8f"
+ dependencies:
+ object-visit "^1.0.0"
+
+mem@^1.1.0:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/mem/-/mem-1.1.0.tgz#5edd52b485ca1d900fe64895505399a0dfa45f76"
+ dependencies:
+ mimic-fn "^1.0.0"
+
+merge-stream@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-1.0.1.tgz#4041202d508a342ba00174008df0c251b8c135e1"
+ dependencies:
+ readable-stream "^2.0.1"
+
+merge@^1.1.3:
+ version "1.2.0"
+ resolved "https://registry.yarnpkg.com/merge/-/merge-1.2.0.tgz#7531e39d4949c281a66b8c5a6e0265e8b05894da"
+
+micromatch@^2.3.11:
+ version "2.3.11"
+ resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565"
+ dependencies:
+ arr-diff "^2.0.0"
+ array-unique "^0.2.1"
+ braces "^1.8.2"
+ expand-brackets "^0.1.4"
+ extglob "^0.3.1"
+ filename-regex "^2.0.0"
+ is-extglob "^1.0.0"
+ is-glob "^2.0.1"
+ kind-of "^3.0.2"
+ normalize-path "^2.0.1"
+ object.omit "^2.0.0"
+ parse-glob "^3.0.4"
+ regex-cache "^0.4.2"
+
+micromatch@^3.1.4, micromatch@^3.1.8:
+ version "3.1.10"
+ resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23"
+ dependencies:
+ arr-diff "^4.0.0"
+ array-unique "^0.3.2"
+ braces "^2.3.1"
+ define-property "^2.0.2"
+ extend-shallow "^3.0.2"
+ extglob "^2.0.4"
+ fragment-cache "^0.2.1"
+ kind-of "^6.0.2"
+ nanomatch "^1.2.9"
+ object.pick "^1.3.0"
+ regex-not "^1.0.0"
+ snapdragon "^0.8.1"
+ to-regex "^3.0.2"
+
+mime-db@~1.33.0:
+ version "1.33.0"
+ resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.33.0.tgz#a3492050a5cb9b63450541e39d9788d2272783db"
+
+mime-types@^2.1.12, mime-types@~2.1.17, mime-types@~2.1.7:
+ version "2.1.18"
+ resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.18.tgz#6f323f60a83d11146f831ff11fd66e2fe5503bb8"
+ dependencies:
+ mime-db "~1.33.0"
+
mimic-fn@^1.0.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022"
-minimatch@^3.0.2, minimatch@^3.0.4:
+minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
dependencies:
@@ -626,11 +2376,22 @@ minimist@0.0.8:
version "0.0.8"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
-minimist@~1.2.0:
+minimist@^1.1.1, minimist@^1.2.0, minimist@~1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
-mkdirp@^0.5.1:
+minimist@~0.0.1:
+ version "0.0.10"
+ resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf"
+
+mixin-deep@^1.2.0:
+ version "1.3.1"
+ resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.1.tgz#a49e7268dce1a0d9698e45326c5626df3543d0fe"
+ dependencies:
+ for-in "^1.0.2"
+ is-extendable "^1.0.1"
+
+"mkdirp@>=0.5 0", mkdirp@^0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
dependencies:
@@ -644,14 +2405,121 @@ mute-stream@0.0.7:
version "0.0.7"
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab"
+nan@^2.3.0:
+ version "2.10.0"
+ resolved "https://registry.yarnpkg.com/nan/-/nan-2.10.0.tgz#96d0cd610ebd58d4b4de9cc0c6828cda99c7548f"
+
+nanomatch@^1.2.9:
+ version "1.2.9"
+ resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.9.tgz#879f7150cb2dab7a471259066c104eee6e0fa7c2"
+ dependencies:
+ arr-diff "^4.0.0"
+ array-unique "^0.3.2"
+ define-property "^2.0.2"
+ extend-shallow "^3.0.2"
+ fragment-cache "^0.2.1"
+ is-odd "^2.0.0"
+ is-windows "^1.0.2"
+ kind-of "^6.0.2"
+ object.pick "^1.3.0"
+ regex-not "^1.0.0"
+ snapdragon "^0.8.1"
+ to-regex "^3.0.1"
+
natural-compare@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
-object-assign@^4.0.1:
+node-int64@^0.4.0:
+ version "0.4.0"
+ resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
+
+node-notifier@^5.2.1:
+ version "5.2.1"
+ resolved "https://registry.yarnpkg.com/node-notifier/-/node-notifier-5.2.1.tgz#fa313dd08f5517db0e2502e5758d664ac69f9dea"
+ dependencies:
+ growly "^1.3.0"
+ semver "^5.4.1"
+ shellwords "^0.1.1"
+ which "^1.3.0"
+
+node-pre-gyp@^0.6.39:
+ version "0.6.39"
+ resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.39.tgz#c00e96860b23c0e1420ac7befc5044e1d78d8649"
+ dependencies:
+ detect-libc "^1.0.2"
+ hawk "3.1.3"
+ mkdirp "^0.5.1"
+ nopt "^4.0.1"
+ npmlog "^4.0.2"
+ rc "^1.1.7"
+ request "2.81.0"
+ rimraf "^2.6.1"
+ semver "^5.3.0"
+ tar "^2.2.1"
+ tar-pack "^3.4.0"
+
+nopt@^4.0.1:
+ version "4.0.1"
+ resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.1.tgz#d0d4685afd5415193c8c7505602d0d17cd64474d"
+ dependencies:
+ abbrev "1"
+ osenv "^0.1.4"
+
+normalize-package-data@^2.3.2:
+ version "2.4.0"
+ resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.4.0.tgz#12f95a307d58352075a04907b84ac8be98ac012f"
+ dependencies:
+ hosted-git-info "^2.1.4"
+ is-builtin-module "^1.0.0"
+ semver "2 || 3 || 4 || 5"
+ validate-npm-package-license "^3.0.1"
+
+normalize-path@^2.0.1, normalize-path@^2.1.1:
+ version "2.1.1"
+ resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9"
+ dependencies:
+ remove-trailing-separator "^1.0.1"
+
+npm-run-path@^2.0.0:
+ version "2.0.2"
+ resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f"
+ dependencies:
+ path-key "^2.0.0"
+
+npmlog@^4.0.2:
+ version "4.1.2"
+ resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b"
+ dependencies:
+ are-we-there-yet "~1.1.2"
+ console-control-strings "~1.1.0"
+ gauge "~2.7.3"
+ set-blocking "~2.0.0"
+
+number-is-nan@^1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d"
+
+nwmatcher@^1.4.3:
+ version "1.4.4"
+ resolved "https://registry.yarnpkg.com/nwmatcher/-/nwmatcher-1.4.4.tgz#2285631f34a95f0d0395cd900c96ed39b58f346e"
+
+oauth-sign@~0.8.1, oauth-sign@~0.8.2:
+ version "0.8.2"
+ resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43"
+
+object-assign@^4.0.1, object-assign@^4.1.0:
version "4.1.1"
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
+object-copy@^0.1.0:
+ version "0.1.0"
+ resolved "https://registry.yarnpkg.com/object-copy/-/object-copy-0.1.0.tgz#7e7d858b781bd7c991a41ba975ed3812754e998c"
+ dependencies:
+ copy-descriptor "^0.1.0"
+ define-property "^0.2.5"
+ kind-of "^3.0.3"
+
object-inspect@~1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.5.0.tgz#9d876c11e40f485c79215670281b767488f9bfe3"
@@ -664,7 +2532,33 @@ object-keys@~0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-0.4.0.tgz#28a6aae7428dd2c3a92f3d95f21335dd204e0336"
-once@^1.3.0:
+object-visit@^1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/object-visit/-/object-visit-1.0.1.tgz#f79c4493af0c5377b59fe39d395e41042dd045bb"
+ dependencies:
+ isobject "^3.0.0"
+
+object.getownpropertydescriptors@^2.0.3:
+ version "2.0.3"
+ resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz#8758c846f5b407adab0f236e0986f14b051caa16"
+ dependencies:
+ define-properties "^1.1.2"
+ es-abstract "^1.5.1"
+
+object.omit@^2.0.0:
+ version "2.0.1"
+ resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa"
+ dependencies:
+ for-own "^0.1.4"
+ is-extendable "^0.1.1"
+
+object.pick@^1.3.0:
+ version "1.3.0"
+ resolved "https://registry.yarnpkg.com/object.pick/-/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747"
+ dependencies:
+ isobject "^3.0.1"
+
+once@^1.3.0, once@^1.3.3, once@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
dependencies:
@@ -676,7 +2570,14 @@ onetime@^2.0.0:
dependencies:
mimic-fn "^1.0.0"
-optionator@^0.8.2:
+optimist@^0.6.1:
+ version "0.6.1"
+ resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686"
+ dependencies:
+ minimist "~0.0.1"
+ wordwrap "~0.0.2"
+
+optionator@^0.8.1, optionator@^0.8.2:
version "0.8.2"
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64"
dependencies:
@@ -687,11 +2588,83 @@ optionator@^0.8.2:
type-check "~0.3.2"
wordwrap "~1.0.0"
-os-tmpdir@~1.0.2:
+os-homedir@^1.0.0:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3"
+
+os-locale@^2.0.0:
+ version "2.1.0"
+ resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-2.1.0.tgz#42bc2900a6b5b8bd17376c8e882b65afccf24bf2"
+ dependencies:
+ execa "^0.7.0"
+ lcid "^1.0.0"
+ mem "^1.1.0"
+
+os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274"
-path-is-absolute@^1.0.0:
+osenv@^0.1.4:
+ version "0.1.5"
+ resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.5.tgz#85cdfafaeb28e8677f416e287592b5f3f49ea410"
+ dependencies:
+ os-homedir "^1.0.0"
+ os-tmpdir "^1.0.0"
+
+p-finally@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae"
+
+p-limit@^1.1.0:
+ version "1.2.0"
+ resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.2.0.tgz#0e92b6bedcb59f022c13d0f1949dc82d15909f1c"
+ dependencies:
+ p-try "^1.0.0"
+
+p-locate@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43"
+ dependencies:
+ p-limit "^1.1.0"
+
+p-try@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3"
+
+parse-glob@^3.0.4:
+ version "3.0.4"
+ resolved "https://registry.yarnpkg.com/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c"
+ dependencies:
+ glob-base "^0.3.0"
+ is-dotfile "^1.0.0"
+ is-extglob "^1.0.0"
+ is-glob "^2.0.0"
+
+parse-json@^2.2.0:
+ version "2.2.0"
+ resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9"
+ dependencies:
+ error-ex "^1.2.0"
+
+parse5@4.0.0:
+ version "4.0.0"
+ resolved "https://registry.yarnpkg.com/parse5/-/parse5-4.0.0.tgz#6d78656e3da8d78b4ec0b906f7c08ef1dfe3f608"
+
+pascalcase@^0.1.1:
+ version "0.1.1"
+ resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14"
+
+path-exists@^2.0.0:
+ version "2.1.0"
+ resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b"
+ dependencies:
+ pinkie-promise "^2.0.0"
+
+path-exists@^3.0.0:
+ version "3.0.0"
+ resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515"
+
+path-is-absolute@^1.0.0, path-is-absolute@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
@@ -699,10 +2672,30 @@ path-is-inside@^1.0.1, path-is-inside@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53"
+path-key@^2.0.0:
+ version "2.0.1"
+ resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"
+
path-parse@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1"
+path-type@^1.0.0:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441"
+ dependencies:
+ graceful-fs "^4.1.2"
+ pify "^2.0.0"
+ pinkie-promise "^2.0.0"
+
+performance-now@^0.2.0:
+ version "0.2.0"
+ resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-0.2.0.tgz#33ef30c5c77d4ea21c5a53869d91b56d8f2555e5"
+
+performance-now@^2.1.0:
+ version "2.1.0"
+ resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
+
pify@^2.0.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
@@ -717,14 +2710,43 @@ pinkie@^2.0.0:
version "2.0.4"
resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870"
+pkg-dir@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-2.0.0.tgz#f6d5d1109e19d63edf428e0bd57e12777615334b"
+ dependencies:
+ find-up "^2.1.0"
+
pluralize@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-7.0.0.tgz#298b89df8b93b0221dbf421ad2b1b1ea23fc6777"
+pn@^1.1.0:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/pn/-/pn-1.1.0.tgz#e2f4cef0e219f463c179ab37463e4e1ecdccbafb"
+
+posix-character-classes@^0.1.0:
+ version "0.1.1"
+ resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
+
prelude-ls@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
+preserve@^0.2.0:
+ version "0.2.0"
+ resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
+
+pretty-format@^22.4.3:
+ version "22.4.3"
+ resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-22.4.3.tgz#f873d780839a9c02e9664c8a082e9ee79eaac16f"
+ dependencies:
+ ansi-regex "^3.0.0"
+ ansi-styles "^3.2.0"
+
+private@^0.1.7:
+ version "0.1.8"
+ resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff"
+
process-nextick-args@~2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa"
@@ -737,7 +2759,54 @@ pseudomap@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"
-readable-stream@^2.2.2:
+punycode@^1.4.1:
+ version "1.4.1"
+ resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e"
+
+punycode@^2.1.0:
+ version "2.1.0"
+ resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.0.tgz#5f863edc89b96db09074bad7947bf09056ca4e7d"
+
+qs@~6.4.0:
+ version "6.4.0"
+ resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233"
+
+qs@~6.5.1:
+ version "6.5.1"
+ resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8"
+
+randomatic@^1.1.3:
+ version "1.1.7"
+ resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-1.1.7.tgz#c7abe9cc8b87c0baa876b19fde83fd464797e38c"
+ dependencies:
+ is-number "^3.0.0"
+ kind-of "^4.0.0"
+
+rc@^1.1.7:
+ version "1.2.6"
+ resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.6.tgz#eb18989c6d4f4f162c399f79ddd29f3835568092"
+ dependencies:
+ deep-extend "~0.4.0"
+ ini "~1.3.0"
+ minimist "^1.2.0"
+ strip-json-comments "~2.0.1"
+
+read-pkg-up@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02"
+ dependencies:
+ find-up "^1.0.0"
+ read-pkg "^1.0.0"
+
+read-pkg@^1.0.0:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28"
+ dependencies:
+ load-json-file "^1.0.0"
+ normalize-package-data "^2.3.2"
+ path-type "^1.0.0"
+
+readable-stream@^2.0.1, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.2.2:
version "2.3.5"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.5.tgz#b4f85003a938cbb6ecbce2a124fb1012bd1a838d"
dependencies:
@@ -762,10 +2831,127 @@ readline-sync@^1.4.9:
version "1.4.9"
resolved "https://registry.yarnpkg.com/readline-sync/-/readline-sync-1.4.9.tgz#3eda8e65f23cd2a17e61301b1f0003396af5ecda"
+realpath-native@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/realpath-native/-/realpath-native-1.0.0.tgz#7885721a83b43bd5327609f0ddecb2482305fdf0"
+ dependencies:
+ util.promisify "^1.0.0"
+
+regenerator-runtime@^0.11.0:
+ version "0.11.1"
+ resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9"
+
+regex-cache@^0.4.2:
+ version "0.4.4"
+ resolved "https://registry.yarnpkg.com/regex-cache/-/regex-cache-0.4.4.tgz#75bdc58a2a1496cec48a12835bc54c8d562336dd"
+ dependencies:
+ is-equal-shallow "^0.1.3"
+
+regex-not@^1.0.0, regex-not@^1.0.2:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c"
+ dependencies:
+ extend-shallow "^3.0.2"
+ safe-regex "^1.1.0"
+
regexpp@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-1.1.0.tgz#0e3516dd0b7904f413d2d4193dce4618c3a689ab"
+remove-trailing-separator@^1.0.1:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef"
+
+repeat-element@^1.1.2:
+ version "1.1.2"
+ resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a"
+
+repeat-string@^1.5.2, repeat-string@^1.6.1:
+ version "1.6.1"
+ resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637"
+
+repeating@^2.0.0:
+ version "2.0.1"
+ resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda"
+ dependencies:
+ is-finite "^1.0.0"
+
+request-promise-core@1.1.1:
+ version "1.1.1"
+ resolved "https://registry.yarnpkg.com/request-promise-core/-/request-promise-core-1.1.1.tgz#3eee00b2c5aa83239cfb04c5700da36f81cd08b6"
+ dependencies:
+ lodash "^4.13.1"
+
+request-promise-native@^1.0.5:
+ version "1.0.5"
+ resolved "https://registry.yarnpkg.com/request-promise-native/-/request-promise-native-1.0.5.tgz#5281770f68e0c9719e5163fd3fab482215f4fda5"
+ dependencies:
+ request-promise-core "1.1.1"
+ stealthy-require "^1.1.0"
+ tough-cookie ">=2.3.3"
+
+request@2.81.0:
+ version "2.81.0"
+ resolved "https://registry.yarnpkg.com/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0"
+ dependencies:
+ aws-sign2 "~0.6.0"
+ aws4 "^1.2.1"
+ caseless "~0.12.0"
+ combined-stream "~1.0.5"
+ extend "~3.0.0"
+ forever-agent "~0.6.1"
+ form-data "~2.1.1"
+ har-validator "~4.2.1"
+ hawk "~3.1.3"
+ http-signature "~1.1.0"
+ is-typedarray "~1.0.0"
+ isstream "~0.1.2"
+ json-stringify-safe "~5.0.1"
+ mime-types "~2.1.7"
+ oauth-sign "~0.8.1"
+ performance-now "^0.2.0"
+ qs "~6.4.0"
+ safe-buffer "^5.0.1"
+ stringstream "~0.0.4"
+ tough-cookie "~2.3.0"
+ tunnel-agent "^0.6.0"
+ uuid "^3.0.0"
+
+request@^2.83.0:
+ version "2.85.0"
+ resolved "https://registry.yarnpkg.com/request/-/request-2.85.0.tgz#5a03615a47c61420b3eb99b7dba204f83603e1fa"
+ dependencies:
+ aws-sign2 "~0.7.0"
+ aws4 "^1.6.0"
+ caseless "~0.12.0"
+ combined-stream "~1.0.5"
+ extend "~3.0.1"
+ forever-agent "~0.6.1"
+ form-data "~2.3.1"
+ har-validator "~5.0.3"
+ hawk "~6.0.2"
+ http-signature "~1.2.0"
+ is-typedarray "~1.0.0"
+ isstream "~0.1.2"
+ json-stringify-safe "~5.0.1"
+ mime-types "~2.1.17"
+ oauth-sign "~0.8.2"
+ performance-now "^2.1.0"
+ qs "~6.5.1"
+ safe-buffer "^5.1.1"
+ stringstream "~0.0.5"
+ tough-cookie "~2.3.3"
+ tunnel-agent "^0.6.0"
+ uuid "^3.1.0"
+
+require-directory@^2.1.1:
+ version "2.1.1"
+ resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
+
+require-main-filename@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1"
+
require-uncached@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/require-uncached/-/require-uncached-1.0.3.tgz#4e0d56d6c9662fd31e43011c4b95aa49955421d3"
@@ -773,10 +2959,28 @@ require-uncached@^1.0.3:
caller-path "^0.1.0"
resolve-from "^1.0.0"
+resolve-cwd@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-2.0.0.tgz#00a9f7387556e27038eae232caa372a6a59b665a"
+ dependencies:
+ resolve-from "^3.0.0"
+
resolve-from@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226"
+resolve-from@^3.0.0:
+ version "3.0.0"
+ resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-3.0.0.tgz#b22c7af7d9d6881bc8b6e653335eebcb0a188748"
+
+resolve-url@^0.2.1:
+ version "0.2.1"
+ resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
+
+resolve@1.1.7:
+ version "1.1.7"
+ resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
+
resolve@~1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.5.0.tgz#1f09acce796c9a762579f31b2c1cc4c3cddf9f36"
@@ -796,7 +3000,17 @@ resumer@~0.0.0:
dependencies:
through "~2.3.4"
-rimraf@^2.2.8:
+ret@~0.1.10:
+ version "0.1.15"
+ resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc"
+
+right-align@^0.1.1:
+ version "0.1.3"
+ resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef"
+ dependencies:
+ align-text "^0.1.1"
+
+rimraf@2, rimraf@^2.2.8, rimraf@^2.5.1, rimraf@^2.5.4, rimraf@^2.6.1:
version "2.6.2"
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36"
dependencies:
@@ -818,14 +3032,60 @@ rx-lite@*, rx-lite@^4.0.8:
version "4.0.8"
resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-4.0.8.tgz#0b1e11af8bc44836f04a6407e92da42467b79444"
-safe-buffer@~5.1.0, safe-buffer@~5.1.1:
+safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853"
-semver@^5.3.0:
+safe-regex@^1.1.0:
+ version "1.1.0"
+ resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e"
+ dependencies:
+ ret "~0.1.10"
+
+sane@^2.0.0:
+ version "2.5.0"
+ resolved "https://registry.yarnpkg.com/sane/-/sane-2.5.0.tgz#6359cd676f5efd9988b264d8ce3b827dd6b27bec"
+ dependencies:
+ anymatch "^2.0.0"
+ exec-sh "^0.2.0"
+ fb-watchman "^2.0.0"
+ micromatch "^3.1.4"
+ minimist "^1.1.1"
+ walker "~1.0.5"
+ watch "~0.18.0"
+ optionalDependencies:
+ fsevents "^1.1.1"
+
+sax@^1.2.4:
+ version "1.2.4"
+ resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
+
+"semver@2 || 3 || 4 || 5", semver@^5.3.0, semver@^5.4.1:
version "5.5.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab"
+set-blocking@^2.0.0, set-blocking@~2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"
+
+set-value@^0.4.3:
+ version "0.4.3"
+ resolved "https://registry.yarnpkg.com/set-value/-/set-value-0.4.3.tgz#7db08f9d3d22dc7f78e53af3c3bf4666ecdfccf1"
+ dependencies:
+ extend-shallow "^2.0.1"
+ is-extendable "^0.1.1"
+ is-plain-object "^2.0.1"
+ to-object-path "^0.3.0"
+
+set-value@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.0.tgz#71ae4a88f0feefbbf52d1ea604f3fb315ebb6274"
+ dependencies:
+ extend-shallow "^2.0.1"
+ is-extendable "^0.1.1"
+ is-plain-object "^2.0.3"
+ split-string "^3.0.1"
+
shebang-command@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea"
@@ -836,16 +3096,131 @@ shebang-regex@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"
-signal-exit@^3.0.2:
+shellwords@^0.1.1:
+ version "0.1.1"
+ resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b"
+
+signal-exit@^3.0.0, signal-exit@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"
+slash@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"
+
slice-ansi@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-1.0.0.tgz#044f1a49d8842ff307aad6b505ed178bd950134d"
dependencies:
is-fullwidth-code-point "^2.0.0"
+snapdragon-node@^2.0.1:
+ version "2.1.1"
+ resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b"
+ dependencies:
+ define-property "^1.0.0"
+ isobject "^3.0.0"
+ snapdragon-util "^3.0.1"
+
+snapdragon-util@^3.0.1:
+ version "3.0.1"
+ resolved "https://registry.yarnpkg.com/snapdragon-util/-/snapdragon-util-3.0.1.tgz#f956479486f2acd79700693f6f7b805e45ab56e2"
+ dependencies:
+ kind-of "^3.2.0"
+
+snapdragon@^0.8.1:
+ version "0.8.2"
+ resolved "https://registry.yarnpkg.com/snapdragon/-/snapdragon-0.8.2.tgz#64922e7c565b0e14204ba1aa7d6964278d25182d"
+ dependencies:
+ base "^0.11.1"
+ debug "^2.2.0"
+ define-property "^0.2.5"
+ extend-shallow "^2.0.1"
+ map-cache "^0.2.2"
+ source-map "^0.5.6"
+ source-map-resolve "^0.5.0"
+ use "^3.1.0"
+
+sntp@1.x.x:
+ version "1.0.9"
+ resolved "https://registry.yarnpkg.com/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198"
+ dependencies:
+ hoek "2.x.x"
+
+sntp@2.x.x:
+ version "2.1.0"
+ resolved "https://registry.yarnpkg.com/sntp/-/sntp-2.1.0.tgz#2c6cec14fedc2222739caf9b5c3d85d1cc5a2cc8"
+ dependencies:
+ hoek "4.x.x"
+
+source-map-resolve@^0.5.0:
+ version "0.5.1"
+ resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.1.tgz#7ad0f593f2281598e854df80f19aae4b92d7a11a"
+ dependencies:
+ atob "^2.0.0"
+ decode-uri-component "^0.2.0"
+ resolve-url "^0.2.1"
+ source-map-url "^0.4.0"
+ urix "^0.1.0"
+
+source-map-support@^0.4.15:
+ version "0.4.18"
+ resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.18.tgz#0286a6de8be42641338594e97ccea75f0a2c585f"
+ dependencies:
+ source-map "^0.5.6"
+
+source-map-support@^0.5.0:
+ version "0.5.4"
+ resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.4.tgz#54456efa89caa9270af7cd624cc2f123e51fbae8"
+ dependencies:
+ source-map "^0.6.0"
+
+source-map-url@^0.4.0:
+ version "0.4.0"
+ resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3"
+
+source-map@^0.4.4:
+ version "0.4.4"
+ resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b"
+ dependencies:
+ amdefine ">=0.0.4"
+
+source-map@^0.5.3, source-map@^0.5.6, source-map@^0.5.7, source-map@~0.5.1:
+ version "0.5.7"
+ resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
+
+source-map@^0.6.0, source-map@~0.6.1:
+ version "0.6.1"
+ resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
+
+spdx-correct@^3.0.0:
+ version "3.0.0"
+ resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.0.0.tgz#05a5b4d7153a195bc92c3c425b69f3b2a9524c82"
+ dependencies:
+ spdx-expression-parse "^3.0.0"
+ spdx-license-ids "^3.0.0"
+
+spdx-exceptions@^2.1.0:
+ version "2.1.0"
+ resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz#2c7ae61056c714a5b9b9b2b2af7d311ef5c78fe9"
+
+spdx-expression-parse@^3.0.0:
+ version "3.0.0"
+ resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz#99e119b7a5da00e05491c9fa338b7904823b41d0"
+ dependencies:
+ spdx-exceptions "^2.1.0"
+ spdx-license-ids "^3.0.0"
+
+spdx-license-ids@^3.0.0:
+ version "3.0.0"
+ resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz#7a7cd28470cc6d3a1cfe6d66886f6bc430d3ac87"
+
+split-string@^3.0.1, split-string@^3.0.2:
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2"
+ dependencies:
+ extend-shallow "^3.0.0"
+
sprintf-js@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.1.1.tgz#36be78320afe5801f6cea3ee78b6e5aab940ea0c"
@@ -858,11 +3233,55 @@ sprintf@~0.1.3:
version "0.1.5"
resolved "https://registry.yarnpkg.com/sprintf/-/sprintf-0.1.5.tgz#8f83e39a9317c1a502cb7db8050e51c679f6edcf"
+sshpk@^1.7.0:
+ version "1.14.1"
+ resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.14.1.tgz#130f5975eddad963f1d56f92b9ac6c51fa9f83eb"
+ dependencies:
+ asn1 "~0.2.3"
+ assert-plus "^1.0.0"
+ dashdash "^1.12.0"
+ getpass "^0.1.1"
+ optionalDependencies:
+ bcrypt-pbkdf "^1.0.0"
+ ecc-jsbn "~0.1.1"
+ jsbn "~0.1.0"
+ tweetnacl "~0.14.0"
+
+stack-utils@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-1.0.1.tgz#d4f33ab54e8e38778b0ca5cfd3b3afb12db68620"
+
+static-extend@^0.1.1:
+ version "0.1.2"
+ resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6"
+ dependencies:
+ define-property "^0.2.5"
+ object-copy "^0.1.0"
+
+stealthy-require@^1.1.0:
+ version "1.1.1"
+ resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b"
+
strftime@^0.10.0:
version "0.10.0"
resolved "https://registry.yarnpkg.com/strftime/-/strftime-0.10.0.tgz#b3f0fa419295202a5a289f6d6be9f4909a617193"
-string-width@^2.1.0, string-width@^2.1.1:
+string-length@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/string-length/-/string-length-2.0.0.tgz#d40dbb686a3ace960c1cffca562bf2c45f8363ed"
+ dependencies:
+ astral-regex "^1.0.0"
+ strip-ansi "^4.0.0"
+
+string-width@^1.0.1, string-width@^1.0.2:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3"
+ dependencies:
+ code-point-at "^1.0.0"
+ is-fullwidth-code-point "^1.0.0"
+ strip-ansi "^3.0.0"
+
+string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e"
dependencies:
@@ -887,7 +3306,11 @@ string_decoder@~1.0.3:
dependencies:
safe-buffer "~5.1.0"
-strip-ansi@^3.0.0:
+stringstream@~0.0.4, stringstream@~0.0.5:
+ version "0.0.5"
+ resolved "https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.5.tgz#4e484cd4de5a0bbbee18e46307710a8a81621878"
+
+strip-ansi@^3.0.0, strip-ansi@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf"
dependencies:
@@ -899,6 +3322,20 @@ strip-ansi@^4.0.0:
dependencies:
ansi-regex "^3.0.0"
+strip-bom@3.0.0:
+ version "3.0.0"
+ resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3"
+
+strip-bom@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e"
+ dependencies:
+ is-utf8 "^0.2.0"
+
+strip-eof@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf"
+
strip-json-comments@~2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
@@ -907,12 +3344,22 @@ supports-color@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
+supports-color@^3.1.2:
+ version "3.2.3"
+ resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6"
+ dependencies:
+ has-flag "^1.0.0"
+
supports-color@^5.3.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.3.0.tgz#5b24ac15db80fa927cf5227a4a33fd3c4c7676c0"
dependencies:
has-flag "^3.0.0"
+symbol-tree@^3.2.2:
+ version "3.2.2"
+ resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.2.tgz#ae27db38f660a7ae2e1c3b7d1bc290819b8519e6"
+
table@4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/table/-/table-4.0.2.tgz#a33447375391e766ad34d3486e6e2aedc84d2e36"
@@ -960,10 +3407,45 @@ tape@~2.3.2:
resumer "~0.0.0"
through "~2.3.4"
+tar-pack@^3.4.0:
+ version "3.4.1"
+ resolved "https://registry.yarnpkg.com/tar-pack/-/tar-pack-3.4.1.tgz#e1dbc03a9b9d3ba07e896ad027317eb679a10a1f"
+ dependencies:
+ debug "^2.2.0"
+ fstream "^1.0.10"
+ fstream-ignore "^1.0.5"
+ once "^1.3.3"
+ readable-stream "^2.1.4"
+ rimraf "^2.5.1"
+ tar "^2.2.1"
+ uid-number "^0.0.6"
+
+tar@^2.2.1:
+ version "2.2.1"
+ resolved "https://registry.yarnpkg.com/tar/-/tar-2.2.1.tgz#8e4d2a256c0e2185c6b18ad694aec968b83cb1d1"
+ dependencies:
+ block-stream "*"
+ fstream "^1.0.2"
+ inherits "2"
+
+test-exclude@^4.1.1:
+ version "4.2.1"
+ resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-4.2.1.tgz#dfa222f03480bca69207ca728b37d74b45f724fa"
+ dependencies:
+ arrify "^1.0.1"
+ micromatch "^3.1.8"
+ object-assign "^4.1.0"
+ read-pkg-up "^1.0.1"
+ require-main-filename "^1.0.1"
+
text-table@~0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
+throat@^4.0.0:
+ version "4.1.0"
+ resolved "https://registry.yarnpkg.com/throat/-/throat-4.1.0.tgz#89037cbc92c56ab18926e6ba4cbb200e15672a6a"
+
through2@~0.2.3:
version "0.2.3"
resolved "https://registry.yarnpkg.com/through2/-/through2-0.2.3.tgz#eb3284da4ea311b6cc8ace3653748a52abf25a3f"
@@ -981,6 +3463,62 @@ tmp@^0.0.33:
dependencies:
os-tmpdir "~1.0.2"
+tmpl@1.0.x:
+ version "1.0.4"
+ resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.4.tgz#23640dd7b42d00433911140820e5cf440e521dd1"
+
+to-fast-properties@^1.0.3:
+ version "1.0.3"
+ resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47"
+
+to-object-path@^0.3.0:
+ version "0.3.0"
+ resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af"
+ dependencies:
+ kind-of "^3.0.2"
+
+to-regex-range@^2.1.0:
+ version "2.1.1"
+ resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-2.1.1.tgz#7c80c17b9dfebe599e27367e0d4dd5590141db38"
+ dependencies:
+ is-number "^3.0.0"
+ repeat-string "^1.6.1"
+
+to-regex@^3.0.1, to-regex@^3.0.2:
+ version "3.0.2"
+ resolved "https://registry.yarnpkg.com/to-regex/-/to-regex-3.0.2.tgz#13cfdd9b336552f30b51f33a8ae1b42a7a7599ce"
+ dependencies:
+ define-property "^2.0.2"
+ extend-shallow "^3.0.2"
+ regex-not "^1.0.2"
+ safe-regex "^1.1.0"
+
+tough-cookie@>=2.3.3, tough-cookie@^2.3.3, tough-cookie@~2.3.0, tough-cookie@~2.3.3:
+ version "2.3.4"
+ resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.4.tgz#ec60cee38ac675063ffc97a5c18970578ee83655"
+ dependencies:
+ punycode "^1.4.1"
+
+tr46@^1.0.0:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/tr46/-/tr46-1.0.1.tgz#a8b13fd6bfd2489519674ccde55ba3693b706d09"
+ dependencies:
+ punycode "^2.1.0"
+
+trim-right@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003"
+
+tunnel-agent@^0.6.0:
+ version "0.6.0"
+ resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd"
+ dependencies:
+ safe-buffer "^5.0.1"
+
+tweetnacl@^0.14.3, tweetnacl@~0.14.0:
+ version "0.14.5"
+ resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64"
+
type-check@~0.3.2:
version "0.3.2"
resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72"
@@ -991,36 +3529,230 @@ typedarray@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
+uglify-js@^2.6:
+ version "2.8.29"
+ resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd"
+ dependencies:
+ source-map "~0.5.1"
+ yargs "~3.10.0"
+ optionalDependencies:
+ uglify-to-browserify "~1.0.0"
+
+uglify-to-browserify@~1.0.0:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7"
+
+uid-number@^0.0.6:
+ version "0.0.6"
+ resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81"
+
+union-value@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.0.tgz#5c71c34cb5bad5dcebe3ea0cd08207ba5aa1aea4"
+ dependencies:
+ arr-union "^3.1.0"
+ get-value "^2.0.6"
+ is-extendable "^0.1.1"
+ set-value "^0.4.3"
+
+unset-value@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559"
+ dependencies:
+ has-value "^0.3.1"
+ isobject "^3.0.0"
+
+urix@^0.1.0:
+ version "0.1.0"
+ resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72"
+
+use@^3.1.0:
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/use/-/use-3.1.0.tgz#14716bf03fdfefd03040aef58d8b4b85f3a7c544"
+ dependencies:
+ kind-of "^6.0.2"
+
util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
-which@^1.2.9:
+util.promisify@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/util.promisify/-/util.promisify-1.0.0.tgz#440f7165a459c9a16dc145eb8e72f35687097030"
+ dependencies:
+ define-properties "^1.1.2"
+ object.getownpropertydescriptors "^2.0.3"
+
+uuid@^3.0.0, uuid@^3.1.0:
+ version "3.2.1"
+ resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.2.1.tgz#12c528bb9d58d0b9265d9a2f6f0fe8be17ff1f14"
+
+validate-npm-package-license@^3.0.1:
+ version "3.0.3"
+ resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz#81643bcbef1bdfecd4623793dc4648948ba98338"
+ dependencies:
+ spdx-correct "^3.0.0"
+ spdx-expression-parse "^3.0.0"
+
+verror@1.10.0:
+ version "1.10.0"
+ resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400"
+ dependencies:
+ assert-plus "^1.0.0"
+ core-util-is "1.0.2"
+ extsprintf "^1.2.0"
+
+w3c-hr-time@^1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/w3c-hr-time/-/w3c-hr-time-1.0.1.tgz#82ac2bff63d950ea9e3189a58a65625fedf19045"
+ dependencies:
+ browser-process-hrtime "^0.1.2"
+
+walker@~1.0.5:
+ version "1.0.7"
+ resolved "https://registry.yarnpkg.com/walker/-/walker-1.0.7.tgz#2f7f9b8fd10d677262b18a884e28d19618e028fb"
+ dependencies:
+ makeerror "1.0.x"
+
+watch@~0.18.0:
+ version "0.18.0"
+ resolved "https://registry.yarnpkg.com/watch/-/watch-0.18.0.tgz#28095476c6df7c90c963138990c0a5423eb4b986"
+ dependencies:
+ exec-sh "^0.2.0"
+ minimist "^1.2.0"
+
+webidl-conversions@^4.0.1, webidl-conversions@^4.0.2:
+ version "4.0.2"
+ resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad"
+
+whatwg-encoding@^1.0.1, whatwg-encoding@^1.0.3:
+ version "1.0.3"
+ resolved "https://registry.yarnpkg.com/whatwg-encoding/-/whatwg-encoding-1.0.3.tgz#57c235bc8657e914d24e1a397d3c82daee0a6ba3"
+ dependencies:
+ iconv-lite "0.4.19"
+
+whatwg-mimetype@^2.0.0, whatwg-mimetype@^2.1.0:
+ version "2.1.0"
+ resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-2.1.0.tgz#f0f21d76cbba72362eb609dbed2a30cd17fcc7d4"
+
+whatwg-url@^6.4.0:
+ version "6.4.0"
+ resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-6.4.0.tgz#08fdf2b9e872783a7a1f6216260a1d66cc722e08"
+ dependencies:
+ lodash.sortby "^4.7.0"
+ tr46 "^1.0.0"
+ webidl-conversions "^4.0.1"
+
+which-module@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"
+
+which@^1.2.12, which@^1.2.9, which@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a"
dependencies:
isexe "^2.0.0"
+wide-align@^1.1.0:
+ version "1.1.2"
+ resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.2.tgz#571e0f1b0604636ebc0dfc21b0339bbe31341710"
+ dependencies:
+ string-width "^1.0.2"
+
+window-size@0.1.0:
+ version "0.1.0"
+ resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d"
+
+wordwrap@0.0.2:
+ version "0.0.2"
+ resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f"
+
+wordwrap@~0.0.2:
+ version "0.0.3"
+ resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107"
+
wordwrap@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
+wrap-ansi@^2.0.0:
+ version "2.1.0"
+ resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85"
+ dependencies:
+ string-width "^1.0.1"
+ strip-ansi "^3.0.1"
+
wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
+write-file-atomic@^2.1.0:
+ version "2.3.0"
+ resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.3.0.tgz#1ff61575c2e2a4e8e510d6fa4e243cce183999ab"
+ dependencies:
+ graceful-fs "^4.1.11"
+ imurmurhash "^0.1.4"
+ signal-exit "^3.0.2"
+
write@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/write/-/write-0.2.1.tgz#5fc03828e264cea3fe91455476f7a3c566cb0757"
dependencies:
mkdirp "^0.5.1"
+ws@^4.0.0:
+ version "4.1.0"
+ resolved "https://registry.yarnpkg.com/ws/-/ws-4.1.0.tgz#a979b5d7d4da68bf54efe0408967c324869a7289"
+ dependencies:
+ async-limiter "~1.0.0"
+ safe-buffer "~5.1.0"
+
+xml-name-validator@^3.0.0:
+ version "3.0.0"
+ resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"
+
xtend@~2.1.1:
version "2.1.2"
resolved "https://registry.yarnpkg.com/xtend/-/xtend-2.1.2.tgz#6efecc2a4dad8e6962c4901b337ce7ba87b5d28b"
dependencies:
object-keys "~0.4.0"
+y18n@^3.2.1:
+ version "3.2.1"
+ resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41"
+
yallist@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52"
+
+yargs-parser@^8.1.0:
+ version "8.1.0"
+ resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-8.1.0.tgz#f1376a33b6629a5d063782944da732631e966950"
+ dependencies:
+ camelcase "^4.1.0"
+
+yargs@^10.0.3:
+ version "10.1.2"
+ resolved "https://registry.yarnpkg.com/yargs/-/yargs-10.1.2.tgz#454d074c2b16a51a43e2fb7807e4f9de69ccb5c5"
+ dependencies:
+ cliui "^4.0.0"
+ decamelize "^1.1.1"
+ find-up "^2.1.0"
+ get-caller-file "^1.0.1"
+ os-locale "^2.0.0"
+ require-directory "^2.1.1"
+ require-main-filename "^1.0.1"
+ set-blocking "^2.0.0"
+ string-width "^2.0.0"
+ which-module "^2.0.0"
+ y18n "^3.2.1"
+ yargs-parser "^8.1.0"
+
+yargs@~3.10.0:
+ version "3.10.0"
+ resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.10.0.tgz#f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1"
+ dependencies:
+ camelcase "^1.0.2"
+ cliui "^2.1.0"
+ decamelize "^1.0.0"
+ window-size "0.1.0"