aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/lbaselib.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/lbaselib.js b/tests/lbaselib.js
index 3ddec2d..ab68a5f 100644
--- a/tests/lbaselib.js
+++ b/tests/lbaselib.js
@@ -82,4 +82,48 @@ test('setmetatable, getmetatable', function (t) {
lapi.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 () {
+
+ let bc = toByteCode(luaCode).dataView;
+
+ L = lauxlib.luaL_newstate();
+
+ linit.luaL_openlibs(L);
+
+ lapi.lua_load(L, bc, "test-rawequal");
+
+ lapi.lua_call(L, 0, -1);
+
+ }, "JS Lua program ran without error");
+
+ t.notOk(
+ lapi.lua_toboolean(L, -2),
+ "Correct element(s) on the stack"
+ );
+
+ t.ok(
+ lapi.lua_toboolean(L, -1),
+ "Correct element(s) on the stack"
+ );
}); \ No newline at end of file