aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2018-02-04 15:58:05 -0800
committerdaurnimator <quae@daurnimator.com>2018-02-04 15:58:05 -0800
commitb42f1c3e18bab816203cc34a9af4d1c11e55199b (patch)
treed11f71beb6cb500a2e78b1f37195173e8552903b
parent1f486bd421bba7f93e6119ed9fde711c2799f96d (diff)
downloadfengari-b42f1c3e18bab816203cc34a9af4d1c11e55199b.tar.gz
fengari-b42f1c3e18bab816203cc34a9af4d1c11e55199b.tar.bz2
fengari-b42f1c3e18bab816203cc34a9af4d1c11e55199b.zip
{src/lauxlib.js,tests/test-suite/ltests.js}: Use luastring_eq instead of .join()
-rw-r--r--src/lauxlib.js2
-rw-r--r--tests/test-suite/ltests.js9
2 files changed, 8 insertions, 3 deletions
diff --git a/src/lauxlib.js b/src/lauxlib.js
index 437b6cf..d5b943b 100644
--- a/src/lauxlib.js
+++ b/src/lauxlib.js
@@ -368,7 +368,7 @@ const luaL_checkudata = function(L, ud, tname) {
const luaL_checkoption = function(L, arg, def, lst) {
let name = def ? luaL_optstring(L, arg, def) : luaL_checkstring(L, arg);
for (let i = 0; lst[i]; i++)
- if (lst[i].join('|') === name.join('|'))
+ if (luastring_eq(lst[i], name))
return i;
return luaL_argerror(L, arg, lua_pushfstring(L, to_luastring("invalid option '%s'"), name));
};
diff --git a/tests/test-suite/ltests.js b/tests/test-suite/ltests.js
index 11de5c3..0b47f65 100644
--- a/tests/test-suite/ltests.js
+++ b/tests/test-suite/ltests.js
@@ -4,7 +4,12 @@ const assert = require("assert");
const lua = require('../../src/lua.js');
const lauxlib = require('../../src/lauxlib.js');
-const {luastring_indexOf, to_jsstring, to_luastring} = require("../../src/fengaricore.js");
+const {
+ luastring_eq,
+ luastring_indexOf,
+ to_jsstring,
+ to_luastring
+} = require("../../src/fengaricore.js");
const ljstype = require('../../src/ljstype.js');
const lopcodes = require('../../src/lopcodes.js');
const sprintf = require('sprintf-js').sprintf;
@@ -450,7 +455,7 @@ const runJS = function(L, L1, pc) {
case "tostring": {
let s = lua.lua_tostring(L1, getindex(L, L1, pc));
let s1 = lua.lua_pushstring(L1, s);
- assert((s === null && s1 === null) || s.join('|') === s1.join('|'));
+ assert(luastring_eq(s, s1));
break;
}
case "type": {