diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-06-18 16:52:22 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-06-18 16:52:22 -0300 |
commit | be73f72fcc944a8ebae2c60d2ce84139acb011b9 (patch) | |
tree | 6ba1154c224a4b7af9e5202b4b52e43706faddb1 /testes/errors.lua | |
parent | 3cd9b56ae6002b4ef28d2467abd119606ae625d3 (diff) | |
download | lua-be73f72fcc944a8ebae2c60d2ce84139acb011b9.tar.gz lua-be73f72fcc944a8ebae2c60d2ce84139acb011b9.tar.bz2 lua-be73f72fcc944a8ebae2c60d2ce84139acb011b9.zip |
New function 'setCstacklimit'
Added new functions to dynamically set the C-stack limit
('lua_setCstacklimit' in the C-API, 'debug.setCstacklimit' in Lua).
Diffstat (limited to 'testes/errors.lua')
-rw-r--r-- | testes/errors.lua | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/testes/errors.lua b/testes/errors.lua index 0b12410e..6e7b8004 100644 --- a/testes/errors.lua +++ b/testes/errors.lua | |||
@@ -523,9 +523,13 @@ end | |||
523 | 523 | ||
524 | -- testing syntax limits | 524 | -- testing syntax limits |
525 | 525 | ||
526 | local function testrep (init, rep, close, repc) | 526 | local function testrep (init, rep, close, repc, finalresult) |
527 | local s = init .. string.rep(rep, 100) .. close .. string.rep(repc, 100) | 527 | local s = init .. string.rep(rep, 100) .. close .. string.rep(repc, 100) |
528 | assert(load(s)) -- 100 levels is OK | 528 | local res, msg = load(s) |
529 | assert(res) -- 100 levels is OK | ||
530 | if (finalresult) then | ||
531 | assert(res() == finalresult) | ||
532 | end | ||
529 | s = init .. string.rep(rep, 10000) | 533 | s = init .. string.rep(rep, 10000) |
530 | local res, msg = load(s) -- 10000 levels not ok | 534 | local res, msg = load(s) -- 10000 levels not ok |
531 | assert(not res and (string.find(msg, "too many registers") or | 535 | assert(not res and (string.find(msg, "too many registers") or |
@@ -534,14 +538,14 @@ end | |||
534 | 538 | ||
535 | testrep("local a; a", ",a", "= 1", ",1") -- multiple assignment | 539 | testrep("local a; a", ",a", "= 1", ",1") -- multiple assignment |
536 | testrep("local a; a=", "{", "0", "}") | 540 | testrep("local a; a=", "{", "0", "}") |
537 | testrep("local a; a=", "(", "2", ")") | 541 | testrep("return ", "(", "2", ")", 2) |
538 | testrep("local a; ", "a(", "2", ")") | 542 | testrep("local function a (x) return x end; return ", "a(", "2.2", ")", 2.2) |
539 | testrep("", "do ", "", " end") | 543 | testrep("", "do ", "", " end") |
540 | testrep("", "while a do ", "", " end") | 544 | testrep("", "while a do ", "", " end") |
541 | testrep("local a; ", "if a then else ", "", " end") | 545 | testrep("local a; ", "if a then else ", "", " end") |
542 | testrep("", "function foo () ", "", " end") | 546 | testrep("", "function foo () ", "", " end") |
543 | testrep("local a; a=", "a..", "a", "") | 547 | testrep("local a = ''; return ", "a..", "'a'", "", "a") |
544 | testrep("local a; a=", "a^", "a", "") | 548 | testrep("local a = 1; return ", "a^", "a", "", 1) |
545 | 549 | ||
546 | checkmessage("a = f(x" .. string.rep(",x", 260) .. ")", "too many registers") | 550 | checkmessage("a = f(x" .. string.rep(",x", 260) .. ")", "too many registers") |
547 | 551 | ||