aboutsummaryrefslogtreecommitdiff
path: root/tests/lexparse.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lexparse.js')
-rw-r--r--tests/lexparse.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/lexparse.js b/tests/lexparse.js
index 2b0cc46..2470e5d 100644
--- a/tests/lexparse.js
+++ b/tests/lexparse.js
@@ -373,4 +373,64 @@ 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
+ `, L;
+
+ t.plan(2);
+
+ t.doesNotThrow(function () {
+
+ L = lauxlib.luaL_newstate();
+
+ linit.luaL_openlibs(L);
+
+ lapi.lua_load(L, null, luaCode, "test", "text");
+
+ lapi.lua_call(L, 0, -1);
+
+ }, "JS Lua program ran without error");
+
+ t.strictEqual(
+ lapi.lua_tostring(L, -1),
+ "hello",
+ "Program output is correct"
+ );
+});
+
+
+test('TESTSET (or)', function (t) {
+ let luaCode = `
+ local a = false
+ local b = "hello"
+
+ return a or b
+ `, L;
+
+ t.plan(2);
+
+ t.doesNotThrow(function () {
+
+ L = lauxlib.luaL_newstate();
+
+ linit.luaL_openlibs(L);
+
+ lapi.lua_load(L, null, luaCode, "test", "text");
+
+ lapi.lua_call(L, 0, -1);
+
+ }, "JS Lua program ran without error");
+
+ t.strictEqual(
+ lapi.lua_tostring(L, -1),
+ "hello",
+ "Program output is correct"
+ );
}); \ No newline at end of file