summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-08 10:29:20 +0100
committerBenoit Giannangeli <benoit.giannangeli@boursorama.fr>2017-02-08 10:32:04 +0100
commit01d7a43f5ef8e7a74bad9b39916d553d61b29fc3 (patch)
tree265a99d1117a95c802cd213f490b5bbcfa8d13e2 /tests
parent20846070c7809ac30a0aed3dbd4d04716e1ef1be (diff)
downloadfengari-01d7a43f5ef8e7a74bad9b39916d553d61b29fc3.tar.gz
fengari-01d7a43f5ef8e7a74bad9b39916d553d61b29fc3.tar.bz2
fengari-01d7a43f5ef8e7a74bad9b39916d553d61b29fc3.zip
TEST, TESTSET
Diffstat (limited to 'tests')
-rw-r--r--tests/lvm.js108
1 files changed, 108 insertions, 0 deletions
diff --git a/tests/lvm.js b/tests/lvm.js
index e2454eb..5f19455 100644
--- a/tests/lvm.js
+++ b/tests/lvm.js
@@ -342,4 +342,112 @@ test('EQ', function (t) {
true,
"Program output is correct"
);
+});
+
+
+test('TESTSET (and)', function (t) {
+ let luaCode = `
+ local a = true
+ local b = "hello"
+
+ return a and b
+ `, vm;
+
+ t.plan(2);
+
+ t.comment("Running following code: \n" + luaCode);
+
+ t.doesNotThrow(function () {
+ vm = getVM(luaCode);
+ vm.execute();
+ }, "Program executed without errors");
+
+ t.strictEqual(
+ vm.L.stack[vm.L.top - 1].value,
+ "hello",
+ "Program output is correct"
+ );
+});
+
+
+test('TESTSET (or)', function (t) {
+ let luaCode = `
+ local a = false
+ local b = "hello"
+
+ return a or b
+ `, vm;
+
+ t.plan(2);
+
+ t.comment("Running following code: \n" + luaCode);
+
+ t.doesNotThrow(function () {
+ vm = getVM(luaCode);
+ vm.execute();
+ }, "Program executed without errors");
+
+ t.strictEqual(
+ vm.L.stack[vm.L.top - 1].value,
+ "hello",
+ "Program output is correct"
+ );
+});
+
+
+test('TEST (true)', function (t) {
+ let luaCode = `
+ local a = true
+ local b = "hello"
+
+ if a then
+ return b
+ end
+
+ return "goodbye"
+ `, vm;
+
+ t.plan(2);
+
+ t.comment("Running following code: \n" + luaCode);
+
+ t.doesNotThrow(function () {
+ vm = getVM(luaCode);
+ vm.execute();
+ }, "Program executed without errors");
+
+ t.strictEqual(
+ vm.L.stack[vm.L.top - 1].value,
+ "hello",
+ "Program output is correct"
+ );
+});
+
+
+test('TEST (false)', function (t) {
+ let luaCode = `
+ local a = false
+ local b = "hello"
+
+ if a then
+ return b
+ end
+
+ return "goodbye"
+ `, vm;
+
+ t.plan(2);
+
+ t.comment("Running following code: \n" + luaCode);
+
+ t.doesNotThrow(function () {
+ vm = getVM(luaCode);
+ vm.execute();
+ }, "Program executed without errors");
+
+ t.strictEqual(
+ vm.L.stack[vm.L.top - 1].value,
+ "goodbye",
+ "Program output is correct"
+ );
}); \ No newline at end of file