summaryrefslogtreecommitdiff
path: root/tests/test-suite/constructs.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-12-10 02:22:47 +1100
committerdaurnimator <quae@daurnimator.com>2017-12-10 02:36:36 +1100
commita946df6302452323706f715a28029c63f766d1db (patch)
tree971f4f82ecb648dc08a96e1a1a25bc7ef1598a0c /tests/test-suite/constructs.js
parentfa8ba4f04623f66962c9fa2a502dd8d51a3eefa6 (diff)
downloadfengari-a946df6302452323706f715a28029c63f766d1db.tar.gz
fengari-a946df6302452323706f715a28029c63f766d1db.tar.bz2
fengari-a946df6302452323706f715a28029c63f766d1db.zip
tests/: Fix linter complaints
Diffstat (limited to 'tests/test-suite/constructs.js')
-rw-r--r--tests/test-suite/constructs.js152
1 files changed, 75 insertions, 77 deletions
diff --git a/tests/test-suite/constructs.js b/tests/test-suite/constructs.js
index f180195..89bcce7 100644
--- a/tests/test-suite/constructs.js
+++ b/tests/test-suite/constructs.js
@@ -19,7 +19,7 @@ test('[test-suite] constructs: testing semicolons', function (t) {
; do ; a = 3; assert(a == 3) end;
;
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -45,7 +45,7 @@ test('[test-suite] constructs: invalid operations should not raise errors when n
let luaCode = `
if false then a = 3 // 0; a = 0 % 0 end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -110,7 +110,7 @@ test('[test-suite] constructs: testing priorities', function (t) {
assert(1234567890 == tonumber('1234567890') and 1234567890+1 == 1234567891)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -296,7 +296,7 @@ test('[test-suite] constructs: silly loops', function (t) {
a,b = F(1)~=nil; assert(a == true and b == nil);
a,b = F(nil)==nil; assert(a == true and b == nil)
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {
@@ -317,94 +317,92 @@ test('[test-suite] constructs: silly loops', function (t) {
});
-if (false) {
- test('[test-suite] constructs: huge loops, upvalue', function (t) {
- let luaCode = `
- -- sometimes will be 0, sometimes will not...
- _ENV.GLOB1 = math.floor(os.time()) % 2
-
- -- basic expressions with their respective values
- local basiccases = {
- {"nil", nil},
- {"false", false},
- {"true", true},
- {"10", 10},
- {"(0==_ENV.GLOB1)", 0 == _ENV.GLOB1},
- }
-
- print('testing short-circuit optimizations (' .. _ENV.GLOB1 .. ')')
-
-
- -- operators with their respective values
- local binops = {
- {" and ", function (a,b) if not a then return a else return b end end},
- {" or ", function (a,b) if a then return a else return b end end},
- }
-
- local cases = {}
-
- -- creates all combinations of '(cases[i] op cases[n-i])' plus
- -- 'not(cases[i] op cases[n-i])' (syntax + value)
- local function createcases (n)
- local res = {}
- for i = 1, n - 1 do
- for _, v1 in ipairs(cases[i]) do
- for _, v2 in ipairs(cases[n - i]) do
- for _, op in ipairs(binops) do
- local t = {
- "(" .. v1[1] .. op[1] .. v2[1] .. ")",
- op[2](v1[2], v2[2])
- }
- res[#res + 1] = t
- res[#res + 1] = {"not" .. t[1], not t[2]}
- end
- end
+test.skip('[test-suite] constructs: huge loops, upvalue', function (t) {
+ let luaCode = `
+ -- sometimes will be 0, sometimes will not...
+ _ENV.GLOB1 = math.floor(os.time()) % 2
+
+ -- basic expressions with their respective values
+ local basiccases = {
+ {"nil", nil},
+ {"false", false},
+ {"true", true},
+ {"10", 10},
+ {"(0==_ENV.GLOB1)", 0 == _ENV.GLOB1},
+ }
+
+ print('testing short-circuit optimizations (' .. _ENV.GLOB1 .. ')')
+
+
+ -- operators with their respective values
+ local binops = {
+ {" and ", function (a,b) if not a then return a else return b end end},
+ {" or ", function (a,b) if a then return a else return b end end},
+ }
+
+ local cases = {}
+
+ -- creates all combinations of '(cases[i] op cases[n-i])' plus
+ -- 'not(cases[i] op cases[n-i])' (syntax + value)
+ local function createcases (n)
+ local res = {}
+ for i = 1, n - 1 do
+ for _, v1 in ipairs(cases[i]) do
+ for _, v2 in ipairs(cases[n - i]) do
+ for _, op in ipairs(binops) do
+ local t = {
+ "(" .. v1[1] .. op[1] .. v2[1] .. ")",
+ op[2](v1[2], v2[2])
+ }
+ res[#res + 1] = t
+ res[#res + 1] = {"not" .. t[1], not t[2]}
end
end
- return res
end
+ end
+ return res
+ end
- -- do not do too many combinations for soft tests
- local level = _soft and 3 or 4
+ -- do not do too many combinations for soft tests
+ local level = _soft and 3 or 4
- cases[1] = basiccases
- for i = 2, level do cases[i] = createcases(i) end
+ cases[1] = basiccases
+ for i = 2, level do cases[i] = createcases(i) end
- local prog = [[if %s then IX = true end; return %s]]
+ local prog = [[if %s then IX = true end; return %s]]
- local i = 0
- for n = 1, level do
- for _, v in pairs(cases[n]) do
- local s = v[1]
- local p = load(string.format(prog, s, s), "")
- IX = false
- assert(p() == v[2] and IX == not not v[2])
- i = i + 1
- if i % 60000 == 0 then print('+') end
- end
- end
- `, L;
-
- t.plan(2);
+ local i = 0
+ for n = 1, level do
+ for _, v in pairs(cases[n]) do
+ local s = v[1]
+ local p = load(string.format(prog, s, s), "")
+ IX = false
+ assert(p() == v[2] and IX == not not v[2])
+ i = i + 1
+ if i % 60000 == 0 then print('+') end
+ end
+ end
+ `, L;
- t.doesNotThrow(function () {
+ t.plan(2);
+
+ t.doesNotThrow(function () {
- L = lauxlib.luaL_newstate();
+ L = lauxlib.luaL_newstate();
- lualib.luaL_openlibs(L);
+ lualib.luaL_openlibs(L);
- lauxlib.luaL_loadstring(L, lua.to_luastring(checkload + luaCode));
+ lauxlib.luaL_loadstring(L, lua.to_luastring(checkload + luaCode));
- }, "Lua program loaded without error");
+ }, "Lua program loaded without error");
- t.doesNotThrow(function () {
+ t.doesNotThrow(function () {
- lua.lua_call(L, 0, -1);
+ lua.lua_call(L, 0, -1);
- }, "Lua program ran without error");
+ }, "Lua program ran without error");
- });
-}
+});
test("[test-suite] constructs: testing some syntax errors (chosen through 'gcov')", function (t) {
@@ -421,7 +419,7 @@ test("[test-suite] constructs: testing some syntax errors (chosen through 'gcov'
checkload(s, "too long")
end
`, L;
-
+
t.plan(2);
t.doesNotThrow(function () {