aboutsummaryrefslogtreecommitdiff
path: root/testes
diff options
context:
space:
mode:
Diffstat (limited to 'testes')
-rw-r--r--testes/locals.lua4
-rw-r--r--testes/memerr.lua4
-rw-r--r--testes/vararg.lua22
3 files changed, 15 insertions, 15 deletions
diff --git a/testes/locals.lua b/testes/locals.lua
index 5222802f..6cd10547 100644
--- a/testes/locals.lua
+++ b/testes/locals.lua
@@ -310,7 +310,7 @@ do -- testing presence of second argument
310 local function foo (howtoclose, obj, n) 310 local function foo (howtoclose, obj, n)
311 local ca -- copy of 'a' visible inside its close metamethod 311 local ca -- copy of 'a' visible inside its close metamethod
312 do 312 do
313 local a <close> = func2close(function (... | t) 313 local a <close> = func2close(function (...t)
314 assert(select("#", ...) == n) 314 assert(select("#", ...) == n)
315 assert(t.n == n and t[1] == ca and (t.n < 2 or t[2] == obj)) 315 assert(t.n == n and t[1] == ca and (t.n < 2 or t[2] == obj))
316 ca = 15 -- final value to be returned if howtoclose=="scope" 316 ca = 15 -- final value to be returned if howtoclose=="scope"
@@ -910,7 +910,7 @@ do
910 910
911 local extrares -- result from extra yield (if any) 911 local extrares -- result from extra yield (if any)
912 912
913 local function check (body, extra, ...|t) 913 local function check (body, extra, ...t)
914 local co = coroutine.wrap(body) 914 local co = coroutine.wrap(body)
915 if extra then 915 if extra then
916 extrares = co() -- runs until first (extra) yield 916 extrares = co() -- runs until first (extra) yield
diff --git a/testes/memerr.lua b/testes/memerr.lua
index 69d2ef85..2cc8f481 100644
--- a/testes/memerr.lua
+++ b/testes/memerr.lua
@@ -126,13 +126,13 @@ testamem("coroutine creation", function()
126end) 126end)
127 127
128do -- vararg tables 128do -- vararg tables
129 local function pack (... | t) return t end 129 local function pack (...t) return t end
130 local b = testamem("vararg table", function () 130 local b = testamem("vararg table", function ()
131 return pack(10, 20, 30, 40, "hello") 131 return pack(10, 20, 30, 40, "hello")
132 end) 132 end)
133 assert(b.aloc == 3) -- new table uses three memory blocks 133 assert(b.aloc == 3) -- new table uses three memory blocks
134 -- table optimized away 134 -- table optimized away
135 local function sel (n, ...|arg) return arg[n] + arg.n end 135 local function sel (n, ...arg) return arg[n] + arg.n end
136 local b = testamem("optimized vararg table", 136 local b = testamem("optimized vararg table",
137 function () return sel(2.0, 20, 30) end) 137 function () return sel(2.0, 20, 30) end)
138 assert(b.res == 32 and b.aloc == 0) -- no memory needed for this case 138 assert(b.res == 32 and b.aloc == 0) -- no memory needed for this case
diff --git a/testes/vararg.lua b/testes/vararg.lua
index 840c3eee..a01598ff 100644
--- a/testes/vararg.lua
+++ b/testes/vararg.lua
@@ -3,7 +3,7 @@
3 3
4print('testing vararg') 4print('testing vararg')
5 5
6local function f (a, ...|t) 6local function f (a, ...t)
7 local x = {n = select('#', ...), ...} 7 local x = {n = select('#', ...), ...}
8 assert(x.n == t.n) 8 assert(x.n == t.n)
9 for i = 1, x.n do 9 for i = 1, x.n do
@@ -20,7 +20,7 @@ local function c12 (...)
20 return res, 2 20 return res, 2
21end 21end
22 22
23local function vararg (... | t) return t end 23local function vararg (... t) return t end
24 24
25local call = function (f, args) return f(table.unpack(args, 1, args.n)) end 25local call = function (f, args) return f(table.unpack(args, 1, args.n)) end
26 26
@@ -153,8 +153,8 @@ end
153 153
154 154
155do -- vararg parameter used in nested functions 155do -- vararg parameter used in nested functions
156 local function foo (... | tab1) 156 local function foo (...tab1)
157 return function (... | tab2) 157 return function (...tab2)
158 return {tab1, tab2} 158 return {tab1, tab2}
159 end 159 end
160 end 160 end
@@ -165,11 +165,11 @@ do -- vararg parameter used in nested functions
165end 165end
166 166
167do -- vararg parameter is read-only 167do -- vararg parameter is read-only
168 local st, msg = load("return function (... | t) t = 10 end") 168 local st, msg = load("return function (... t) t = 10 end")
169 assert(string.find(msg, "const variable 't'")) 169 assert(string.find(msg, "const variable 't'"))
170 170
171 local st, msg = load[[ 171 local st, msg = load[[
172 local function foo (... | extra) 172 local function foo (...extra)
173 return function (...) extra = nil end 173 return function (...) extra = nil end
174 end 174 end
175 ]] 175 ]]
@@ -179,19 +179,19 @@ end
179 179
180do -- _ENV as vararg parameter 180do -- _ENV as vararg parameter
181 local st, msg = load[[ 181 local st, msg = load[[
182 local function aux (... | _ENV) 182 local function aux (... _ENV)
183 global <const> a 183 global <const> a
184 a = 10 184 a = 10
185 end ]] 185 end ]]
186 assert(string.find(msg, "const variable 'a'")) 186 assert(string.find(msg, "const variable 'a'"))
187 187
188 local function aux (... | _ENV) 188 local function aux (..._ENV)
189 global a; a = 10 189 global a; a = 10
190 return a 190 return a
191 end 191 end
192 assert(aux() == 10) 192 assert(aux() == 10)
193 193
194 local function aux (... | _ENV) 194 local function aux (... _ENV)
195 global a = 10 195 global a = 10
196 return a 196 return a
197 end 197 end
@@ -200,7 +200,7 @@ end
200 200
201 201
202do -- access to vararg parameter 202do -- access to vararg parameter
203 local function notab (keys, t, ... | v) 203 local function notab (keys, t, ...v)
204 for _, k in pairs(keys) do 204 for _, k in pairs(keys) do
205 assert(t[k] == v[k]) 205 assert(t[k] == v[k])
206 end 206 end
@@ -216,7 +216,7 @@ do -- access to vararg parameter
216 assert(m == collectgarbage"count") 216 assert(m == collectgarbage"count")
217 217
218 -- writing to the vararg table 218 -- writing to the vararg table
219 local function foo (... | t) 219 local function foo (...t)
220 t[1] = t[1] + 10 220 t[1] = t[1] + 10
221 return t[1] 221 return t[1]
222 end 222 end