From 3df5624ff432b340fe122988fe6d025ad3217946 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 21 Aug 2019 12:19:47 -0300 Subject: Fixed bug when yiedling inside OP_ADDK opcode The family of opcodes OP_ADDK (arithmetic operators with K constant) were not being handled in 'luaV_finishOp', which completes their task after an yield. --- testes/coroutine.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'testes') diff --git a/testes/coroutine.lua b/testes/coroutine.lua index 79bbf2ea..26ed1f6a 100644 --- a/testes/coroutine.lua +++ b/testes/coroutine.lua @@ -724,6 +724,17 @@ assert(run(function () return a / b end, {"div"}) == 10/12) assert(run(function () return a % b end, {"mod"}) == 10) assert(run(function () return a // b end, {"idiv"}) == 0) +-- repeat tests with larger constants (to use 'K' opcodes) +local a1000 = new(1000) + +assert(run(function () return a1000 + 1000 end, {"add"}) == 2000) +assert(run(function () return a1000 - 25000 end, {"sub"}) == -24000) +assert(run(function () return 2000 * a end, {"mul"}) == 20000) +assert(run(function () return a1000 / 1000 end, {"div"}) == 1) +assert(run(function () return a1000 % 600 end, {"mod"}) == 400) +assert(run(function () return a1000 // 500 end, {"idiv"}) == 2) + + assert(run(function () return a % b end, {"mod"}) == 10) -- cgit v1.2.3-55-g6feb