diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2021-06-14 13:28:21 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2021-06-14 13:28:21 -0300 |
commit | 04e19712a5d48b84869f9942836ff8314fb0be8e (patch) | |
tree | 75aab8dff5bdf07026080eba0189e4025ec3b7ee /testes | |
parent | 901d76009346d76996679c02deee708bf225e91e (diff) | |
download | lua-04e19712a5d48b84869f9942836ff8314fb0be8e.tar.gz lua-04e19712a5d48b84869f9942836ff8314fb0be8e.tar.bz2 lua-04e19712a5d48b84869f9942836ff8314fb0be8e.zip |
C functions can be tail called, too
A tail call to a C function can have the behavior of a "real" tail
call, reusing the stack frame of the caller.
Diffstat (limited to 'testes')
-rw-r--r-- | testes/coroutine.lua | 2 | ||||
-rw-r--r-- | testes/errors.lua | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/testes/coroutine.lua b/testes/coroutine.lua index b36b76ea..461e0377 100644 --- a/testes/coroutine.lua +++ b/testes/coroutine.lua | |||
@@ -205,7 +205,7 @@ do | |||
205 | co = coroutine.create(function () return pcall(foo) end) | 205 | co = coroutine.create(function () return pcall(foo) end) |
206 | local st1, st2, err = coroutine.resume(co) | 206 | local st1, st2, err = coroutine.resume(co) |
207 | assert(st1 and not st2 and err == 43) | 207 | assert(st1 and not st2 and err == 43) |
208 | assert(X == 43 and Y.name == "pcall") | 208 | assert(X == 43 and Y.what == "C") |
209 | 209 | ||
210 | -- recovering from errors in __close metamethods | 210 | -- recovering from errors in __close metamethods |
211 | local track = {} | 211 | local track = {} |
diff --git a/testes/errors.lua b/testes/errors.lua index a3d0676b..825f37c2 100644 --- a/testes/errors.lua +++ b/testes/errors.lua | |||
@@ -26,7 +26,7 @@ end | |||
26 | 26 | ||
27 | local function checkmessage (prog, msg, debug) | 27 | local function checkmessage (prog, msg, debug) |
28 | local m = doit(prog) | 28 | local m = doit(prog) |
29 | if debug then print(m) end | 29 | if debug then print(m, msg) end |
30 | assert(string.find(m, msg, 1, true)) | 30 | assert(string.find(m, msg, 1, true)) |
31 | end | 31 | end |
32 | 32 | ||
@@ -289,7 +289,7 @@ end]], "global 'insert'") | |||
289 | 289 | ||
290 | checkmessage([[ -- tail call | 290 | checkmessage([[ -- tail call |
291 | return math.sin("a") | 291 | return math.sin("a") |
292 | ]], "'sin'") | 292 | ]], "sin") |
293 | 293 | ||
294 | checkmessage([[collectgarbage("nooption")]], "invalid option") | 294 | checkmessage([[collectgarbage("nooption")]], "invalid option") |
295 | 295 | ||