summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/llex.js2
-rw-r--r--tests/lexparse.js38
2 files changed, 39 insertions, 1 deletions
diff --git a/src/llex.js b/src/llex.js
index 63a1fbb..f90dc47 100644
--- a/src/llex.js
+++ b/src/llex.js
@@ -498,7 +498,7 @@ const llex = function(ls, seminfo) {
}
case '[': { /* long string or simply '[' */
let sep = skip_sep(ls);
- if (sep.charCodeAt(0) >= 0) {
+ if (sep >= 0) {
read_long_string(ls, seminfo, sep);
return R.TK_STRING;
} else if (sep !== -1) /* '[=...' missing second bracket */
diff --git a/tests/lexparse.js b/tests/lexparse.js
index 7a12985..ca77054 100644
--- a/tests/lexparse.js
+++ b/tests/lexparse.js
@@ -533,4 +533,42 @@ test('FORPREP, FORLOOP (float)', function (t) {
60.5,
"Program output is correct"
);
+});
+
+
+test('SETTABLE, GETTABLE', function (t) {
+ let luaCode = `
+ local t = {}
+
+ t[1] = "hello"
+ t["two"] = "world"
+
+ return t
+ `, L;
+
+ t.plan(3);
+
+ t.doesNotThrow(function () {
+
+ L = lauxlib.luaL_newstate();
+
+ linit.luaL_openlibs(L);
+
+ lapi.lua_load(L, null, luaCode, "test", "text");
+
+ lapi.lua_call(L, 0, -1);
+
+ }, "JS Lua program ran without error");
+
+ t.strictEqual(
+ lapi.lua_topointer(L, -1).get(0).value,
+ "hello",
+ "Program output is correct"
+ );
+
+ t.strictEqual(
+ lapi.lua_topointer(L, -1).get("two").value,
+ "world",
+ "Program output is correct"
+ );
}); \ No newline at end of file