summaryrefslogtreecommitdiff
path: root/tests/ltm.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-02-14 21:39:16 +0100
committerBenoit Giannangeli <giann008@gmail.com>2017-02-14 21:40:39 +0100
commit829e47b9bd568c5722e9f59ca05036d2ae912ddf (patch)
tree40d51cbfa9449c0b07e7fb348d20365bc531e2f4 /tests/ltm.js
parent8e19f368c2c40d99a92b39c6f566c7bcb2af6cf7 (diff)
downloadfengari-829e47b9bd568c5722e9f59ca05036d2ae912ddf.tar.gz
fengari-829e47b9bd568c5722e9f59ca05036d2ae912ddf.tar.bz2
fengari-829e47b9bd568c5722e9f59ca05036d2ae912ddf.zip
Launch scripts with luaD_call
Will adjust L.top correctly. Still isn't what lua's doing since we still miss the first 5 elements.
Diffstat (limited to 'tests/ltm.js')
-rw-r--r--tests/ltm.js36
1 files changed, 25 insertions, 11 deletions
diff --git a/tests/ltm.js b/tests/ltm.js
index cacb20b..4aec5d9 100644
--- a/tests/ltm.js
+++ b/tests/ltm.js
@@ -5,6 +5,7 @@ const test = require('tape');
const beautify = require('js-beautify').js_beautify;
const VM = require("../src/lvm.js");
+const ldo = require("../src/ldo.js");
const OC = require('../src/lopcodes.js');
const getState = require("./tests.js").getState;
@@ -22,7 +23,7 @@ test('__index, __newindex: with actual table', function (t) {
t.doesNotThrow(function () {
L = getState(luaCode);
- VM.luaV_execute(L);
+ ldo.luaD_call(L, 0, -1);
}, "Program executed without errors");
t.strictEqual(
@@ -54,7 +55,7 @@ test('__index: with non table', function (t) {
}, "Bytecode parsed without errors");
t.throws(function () {
- VM.luaV_execute(L);
+ ldo.luaD_call(L, 0, -1);
}, "Program executed with expected error");
});
@@ -74,7 +75,7 @@ test('__newindex: with non table', function (t) {
}, "Bytecode parsed without errors");
t.throws(function () {
- VM.luaV_execute(L);
+ ldo.luaD_call(L, 0, -1);
}, "Program executed with expected error");
});
@@ -129,7 +130,7 @@ test('__index function in metatable', function (t) {
L.stack[0].p.code[4].breakpoint = true;
t.doesNotThrow(function () {
- VM.luaV_execute(L);
+ ldo.luaD_call(L, 0, -1);
}, "First part of the program executed without errors");
t.strictEqual(
@@ -220,7 +221,7 @@ test('__newindex function in metatable', function (t) {
L.stack[0].p.code[4].breakpoint = true;
t.doesNotThrow(function () {
- VM.luaV_execute(L);
+ ldo.luaD_call(L, 0, -1);
}, "First part of the program executed without errors");
t.strictEqual(
@@ -305,7 +306,7 @@ test('__index table in metatable', function (t) {
L.stack[0].p.code[5].breakpoint = true;
t.doesNotThrow(function () {
- VM.luaV_execute(L);
+ ldo.luaD_call(L, 0, -1);
}, "First part of the program executed without errors");
t.strictEqual(
@@ -394,7 +395,7 @@ test('__newindex table in metatable', function (t) {
L.stack[0].p.code[5].breakpoint = true;
t.doesNotThrow(function () {
- VM.luaV_execute(L);
+ ldo.luaD_call(L, 0, -1);
}, "First part of the program executed without errors");
t.strictEqual(
@@ -499,7 +500,7 @@ test('__index table with own metatable', function (t) {
L.stack[0].p.code[8].breakpoint = true;
t.doesNotThrow(function () {
- VM.luaV_execute(L);
+ ldo.luaD_call(L, 0, -1);
}, "First part of the program executed without errors");
L.ci.pcOff--;
@@ -604,7 +605,7 @@ test('__newindex table with own metatable', function (t) {
L.stack[0].p.code[8].breakpoint = true;
t.doesNotThrow(function () {
- VM.luaV_execute(L);
+ ldo.luaD_call(L, 0, -1);
}, "First part of the program executed without errors");
L.ci.pcOff--;
@@ -781,7 +782,7 @@ test('binary __xxx functions in metatable', function (t) {
L.stack[0].p.code[26].breakpoint = true;
t.doesNotThrow(function () {
- VM.luaV_execute(L);
+ ldo.luaD_call(L, 0, -1);
}, "First part of the program executed without errors");
L.ci.pcOff--;
@@ -796,7 +797,20 @@ test('binary __xxx functions in metatable', function (t) {
t.deepEqual(
L.stack.slice(L.top - 12, L.top).map(function (e) { return e.value }),
- ["{} + 1", "{} - 1", "{} * 1", "{} % 1", "{} ^ 1", "{} / 1", "{} // 1", "{} & 1", "{} | 1", "{} ~ 1", "{} << 1", "{} >> 1", ],
+ [
+ "{} + 1",
+ "{} - 1",
+ "{} * 1",
+ "{} % 1",
+ "{} ^ 1",
+ "{} / 1",
+ "{} // 1",
+ "{} & 1",
+ "{} | 1",
+ "{} ~ 1",
+ "{} << 1",
+ "{} >> 1"
+ ],
"Program output is correct"
);
}); \ No newline at end of file