From c7b6e2364b3ff9bed781215f57a6398979b287d4 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Tue, 7 Feb 2017 08:40:43 +0100 Subject: GETUPVAL, SETUPVAL --- tests/lvm.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests') diff --git a/tests/lvm.js b/tests/lvm.js index e10ddb2..084a9ad 100644 --- a/tests/lvm.js +++ b/tests/lvm.js @@ -270,4 +270,35 @@ test('VARARG', function (t) { [1, 2, 3], "Program output is correct" ); +}); + + +test('GETUPVAL, SETUPVAL', function (t) { + let luaCode = ` + local a = 1 + + local f = function () + a = a + 1 + return a + end + + f() + + return a + `, 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, + 2, + "Program output is correct" + ); }); \ No newline at end of file -- cgit v1.2.3-54-g00ecf