diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-07-19 17:34:22 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-07-19 17:34:22 -0300 |
commit | f407b3c4a1bc9667867ec51e835c20d97aab55a2 (patch) | |
tree | ad629983fbde70d5446411d765a99a1b724eb82b /testes | |
parent | a546138d158d79d44b2c5b42630be00d306f4e7c (diff) | |
download | lua-f407b3c4a1bc9667867ec51e835c20d97aab55a2.tar.gz lua-f407b3c4a1bc9667867ec51e835c20d97aab55a2.tar.bz2 lua-f407b3c4a1bc9667867ec51e835c20d97aab55a2.zip |
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.
Diffstat (limited to 'testes')
-rw-r--r-- | testes/api.lua | 17 |
1 files changed, 17 insertions, 0 deletions
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 | |||
165 | end | 165 | end |
166 | 166 | ||
167 | 167 | ||
168 | do -- testing multipe returns | ||
169 | local function foo (n) | ||
170 | if n > 0 then return n, foo(n - 1) end | ||
171 | end | ||
172 | |||
173 | local t = {T.testC("call 1 10; return 10", foo, 20)} | ||
174 | assert(t[1] == 20 and t[10] == 11 and t[11] == nil) | ||
175 | |||
176 | local t = table.pack(T.testC("call 1 10; return 10", foo, 2)) | ||
177 | assert(t[1] == 2 and t[2] == 1 and t[3] == nil and t.n == 10) | ||
178 | |||
179 | local t = {T.testC([[ | ||
180 | checkstack 300 "error"; call 1 250; return 250]], foo, 250)} | ||
181 | assert(t[1] == 250 and t[250] == 1 and t[251] == nil) | ||
182 | end | ||
183 | |||
184 | |||
168 | -- testing globals | 185 | -- testing globals |
169 | _G.AA = 14; _G.BB = "a31" | 186 | _G.AA = 14; _G.BB = "a31" |
170 | local a = {T.testC[[ | 187 | local a = {T.testC[[ |