aboutsummaryrefslogtreecommitdiff
path: root/testes
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-09-24 14:31:06 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-09-24 14:31:06 -0300
commit03cde80b58ea7f112f1b7a35c037893093b59f2e (patch)
treed92d64bca2b0ebe3e026fbf7955bf080db17e480 /testes
parent6b2e202df55f3d1f3c670eab65981db6e125c758 (diff)
downloadlua-03cde80b58ea7f112f1b7a35c037893093b59f2e.tar.gz
lua-03cde80b58ea7f112f1b7a35c037893093b59f2e.tar.bz2
lua-03cde80b58ea7f112f1b7a35c037893093b59f2e.zip
'setCstacklimit' renamed to 'setcstacklimit'
Function names in the API use only lowercase letters.
Diffstat (limited to 'testes')
-rw-r--r--testes/cstack.lua24
1 files changed, 12 insertions, 12 deletions
diff --git a/testes/cstack.lua b/testes/cstack.lua
index 2a55ce21..486abc1d 100644
--- a/testes/cstack.lua
+++ b/testes/cstack.lua
@@ -8,7 +8,7 @@ print"If this test craches, see its file ('cstack.lua')"
8 8
9-- Segmentation faults in these tests probably result from a C-stack 9-- Segmentation faults in these tests probably result from a C-stack
10-- overflow. To avoid these errors, you can use the function 10-- overflow. To avoid these errors, you can use the function
11-- 'debug.setCstacklimit' to set a smaller limit for the use of 11-- 'debug.setcstacklimit' to set a smaller limit for the use of
12-- C stack by Lua. After finding a reliable limit, you might want 12-- C stack by Lua. After finding a reliable limit, you might want
13-- to recompile Lua with this limit as the value for 13-- to recompile Lua with this limit as the value for
14-- the constant 'LUAI_MAXCCALLS', which defines the default limit. 14-- the constant 'LUAI_MAXCCALLS', which defines the default limit.
@@ -19,12 +19,12 @@ print"If this test craches, see its file ('cstack.lua')"
19-- higher than 2_000. 19-- higher than 2_000.
20 20
21 21
22local origlimit = debug.setCstacklimit(400) 22local origlimit = debug.setcstacklimit(400)
23print("default stack limit: " .. origlimit) 23print("default stack limit: " .. origlimit)
24 24
25-- change this value for different limits for this test suite 25-- change this value for different limits for this test suite
26local currentlimit = origlimit 26local currentlimit = origlimit
27debug.setCstacklimit(currentlimit) 27debug.setcstacklimit(currentlimit)
28print("current stack limit: " .. currentlimit) 28print("current stack limit: " .. currentlimit)
29 29
30 30
@@ -102,10 +102,10 @@ end
102 102
103do print("testing changes in C-stack limit") 103do print("testing changes in C-stack limit")
104 104
105 assert(not debug.setCstacklimit(0)) -- limit too small 105 assert(not debug.setcstacklimit(0)) -- limit too small
106 assert(not debug.setCstacklimit(50000)) -- limit too large 106 assert(not debug.setcstacklimit(50000)) -- limit too large
107 local co = coroutine.wrap (function () 107 local co = coroutine.wrap (function ()
108 return debug.setCstacklimit(400) 108 return debug.setcstacklimit(400)
109 end) 109 end)
110 assert(co() == false) -- cannot change C stack inside coroutine 110 assert(co() == false) -- cannot change C stack inside coroutine
111 111
@@ -118,26 +118,26 @@ do print("testing changes in C-stack limit")
118 return n 118 return n
119 end 119 end
120 120
121 assert(debug.setCstacklimit(400) == currentlimit) 121 assert(debug.setcstacklimit(400) == currentlimit)
122 local lim400 = check() 122 local lim400 = check()
123 -- a very low limit (given that the several calls to arive here) 123 -- a very low limit (given that the several calls to arive here)
124 local lowlimit = 38 124 local lowlimit = 38
125 assert(debug.setCstacklimit(lowlimit) == 400) 125 assert(debug.setcstacklimit(lowlimit) == 400)
126 assert(check() < lowlimit - 30) 126 assert(check() < lowlimit - 30)
127 assert(debug.setCstacklimit(600) == lowlimit) 127 assert(debug.setcstacklimit(600) == lowlimit)
128 local lim600 = check() 128 local lim600 = check()
129 assert(lim600 == lim400 + 200) 129 assert(lim600 == lim400 + 200)
130 130
131 131
132 -- 'setCstacklimit' works inside protected calls. (The new stack 132 -- 'setcstacklimit' works inside protected calls. (The new stack
133 -- limit is kept when 'pcall' returns.) 133 -- limit is kept when 'pcall' returns.)
134 assert(pcall(function () 134 assert(pcall(function ()
135 assert(debug.setCstacklimit(400) == 600) 135 assert(debug.setcstacklimit(400) == 600)
136 assert(check() <= lim400) 136 assert(check() <= lim400)
137 end)) 137 end))
138 138
139 assert(check() == lim400) 139 assert(check() == lim400)
140 assert(debug.setCstacklimit(origlimit) == 400) -- restore original limit 140 assert(debug.setcstacklimit(origlimit) == 400) -- restore original limit
141end 141end
142 142
143 143