From f407b3c4a1bc9667867ec51e835c20d97aab55a2 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 19 Jul 2024 17:34:22 -0300 Subject: Using CIST_CLSRET instead of trick with 'nresults' The callstatus flag CIST_CLSRET is used in all tests for the presence of variables to be closed in C functions. --- testes/api.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'testes') diff --git a/testes/api.lua b/testes/api.lua index dc485240..ae2f82dd 100644 --- a/testes/api.lua +++ b/testes/api.lua @@ -165,6 +165,23 @@ do -- test returning more results than fit in the caller stack end +do -- testing multipe returns + local function foo (n) + if n > 0 then return n, foo(n - 1) end + end + + local t = {T.testC("call 1 10; return 10", foo, 20)} + assert(t[1] == 20 and t[10] == 11 and t[11] == nil) + + local t = table.pack(T.testC("call 1 10; return 10", foo, 2)) + assert(t[1] == 2 and t[2] == 1 and t[3] == nil and t.n == 10) + + local t = {T.testC([[ + checkstack 300 "error"; call 1 250; return 250]], foo, 250)} + assert(t[1] == 250 and t[250] == 1 and t[251] == nil) +end + + -- testing globals _G.AA = 14; _G.BB = "a31" local a = {T.testC[[ -- cgit v1.2.3-55-g6feb