summaryrefslogtreecommitdiff
path: root/tests/lapi.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-16 12:08:55 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-16 12:08:55 +0100
commit573a9c3b39bf1570a575ce3f077a33e752439165 (patch)
tree79246e5c83604f10d5b6a3767572d3977116c256 /tests/lapi.js
parent739b5c1888b38b2580adbe52a42b86372a7d146b (diff)
downloadfengari-573a9c3b39bf1570a575ce3f077a33e752439165.tar.gz
fengari-573a9c3b39bf1570a575ce3f077a33e752439165.tar.bz2
fengari-573a9c3b39bf1570a575ce3f077a33e752439165.zip
lua_pushvalue
Diffstat (limited to 'tests/lapi.js')
-rw-r--r--tests/lapi.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/lapi.js b/tests/lapi.js
index 6c5d7a4..8dd2680 100644
--- a/tests/lapi.js
+++ b/tests/lapi.js
@@ -168,4 +168,51 @@ test('lua_pushboolean', function (t) {
true,
"top is correct"
);
+});
+
+
+test('lua_pushvalue', function (t) {
+ let L;
+
+ t.plan(6);
+
+ t.doesNotThrow(function () {
+
+ L = lauxlib.luaL_newstate();
+
+ lapi.lua_pushstring(L, "hello");
+
+ lapi.lua_pushvalue(L, -1);
+
+ }, "JS Lua program ran without error");
+
+ t.strictEqual(
+ lapi.lua_gettop(L),
+ 2,
+ "top is correct"
+ );
+
+ t.strictEqual(
+ lauxlib.luaL_typename(L, -1),
+ "string",
+ "Correct element(s) on the stack"
+ );
+
+ t.strictEqual(
+ lauxlib.luaL_typename(L, -2),
+ "string",
+ "Correct element(s) on the stack"
+ );
+
+ t.strictEqual(
+ L.stack[lapi.lua_gettop(L)].value,
+ "hello",
+ "top is correct"
+ );
+
+ t.strictEqual(
+ L.stack[lapi.lua_gettop(L) - 1].value,
+ "hello",
+ "top is correct"
+ );
}); \ No newline at end of file