summaryrefslogtreecommitdiff
path: root/tests/lbaselib.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-20 11:26:28 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-20 11:29:35 +0100
commite0d4ffcc75a04b3ecc2cc08aea372d9621e5b6ac (patch)
treeb7681375fe8f42139d9eab5554704d3899a6a050 /tests/lbaselib.js
parentb62bcdfa67d6b0359bf45930ab392953d69eb399 (diff)
downloadfengari-e0d4ffcc75a04b3ecc2cc08aea372d9621e5b6ac.tar.gz
fengari-e0d4ffcc75a04b3ecc2cc08aea372d9621e5b6ac.tar.bz2
fengari-e0d4ffcc75a04b3ecc2cc08aea372d9621e5b6ac.zip
rawequal
Diffstat (limited to 'tests/lbaselib.js')
-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