summaryrefslogtreecommitdiff
path: root/tests/ltm.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-02-11 22:22:38 +0100
committerBenoit Giannangeli <giann008@gmail.com>2017-02-12 17:00:20 +0100
commit4bf190d1b51c8c2d3f5ab0b6355ecd971b735adc (patch)
tree2d3bb5d29f60d12db379933273d654683c539cf4 /tests/ltm.js
parent3c5cf1687c2da09f56ca1de340e5ada2119efca9 (diff)
downloadfengari-4bf190d1b51c8c2d3f5ab0b6355ecd971b735adc.tar.gz
fengari-4bf190d1b51c8c2d3f5ab0b6355ecd971b735adc.tar.bz2
fengari-4bf190d1b51c8c2d3f5ab0b6355ecd971b735adc.zip
TFORCALL, TFORLOOP, luaD_call, tag methods
Diffstat (limited to 'tests/ltm.js')
-rw-r--r--tests/ltm.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/ltm.js b/tests/ltm.js
new file mode 100644
index 0000000..e1d3e26
--- /dev/null
+++ b/tests/ltm.js
@@ -0,0 +1,37 @@
+/*jshint esversion: 6 */
+"use strict";
+
+const test = require('tape');
+const beautify = require('js-beautify').js_beautify;
+
+const lua_State = require("../src/lstate.js").lua_State;
+const VM = require("../src/lvm.js");
+const Table = require("../src/lobject.js").Table;
+
+const getState = require("./tests.js");
+
+
+test('__add', function (t) {
+ let luaCode = `
+ local t = {}
+ setmetatable(t, {__add = function ()
+ return "hello"
+ end})
+ return t + 1
+ `, L;
+
+ t.plan(2);
+
+ t.comment("Running following code: \n" + luaCode);
+
+ t.doesNotThrow(function () {
+ L = getState(luaCode);
+ VM.luaV_execute(L);
+ }, "Program executed without errors");
+
+ t.strictEqual(
+ L.stack[L.top - 1].value,
+ "hello",
+ "Program output is correct"
+ );
+}); \ No newline at end of file