summaryrefslogtreecommitdiff
path: root/tests/test-suite/events.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test-suite/events.js')
-rw-r--r--tests/test-suite/events.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/test-suite/events.js b/tests/test-suite/events.js
index 8aa7aa7..090b104 100644
--- a/tests/test-suite/events.js
+++ b/tests/test-suite/events.js
@@ -428,3 +428,55 @@ test("[test-suite] events: __eq between userdata", function (t) {
}, "Lua program ran without error");
});
+
+
+test("[test-suite] events: concat", function (t) {
+ let luaCode = `
+ t = {}
+
+ t.__concat = function (a,b,c)
+ assert(c == nil)
+ if type(a) == 'table' then a = a.val end
+ if type(b) == 'table' then b = b.val end
+ if A then return a..b
+ else
+ return setmetatable({val=a..b}, t)
+ end
+ end
+
+ c = {val="c"}; setmetatable(c, t)
+ d = {val="d"}; setmetatable(d, t)
+
+ A = true
+ assert(c..d == 'cd')
+ assert(0 .."a".."b"..c..d.."e".."f"..(5+3).."g" == "0abcdef8g")
+
+ A = false
+ assert((c..d..c..d).val == 'cdcd')
+ x = c..d
+ 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, lua.to_luastring(luaCode));
+
+ }, "Lua program loaded without error");
+
+ t.doesNotThrow(function () {
+
+ lua.lua_call(L, 0, -1);
+
+ }, "Lua program ran without error");
+
+});