aboutsummaryrefslogtreecommitdiff
path: root/testes
diff options
context:
space:
mode:
Diffstat (limited to 'testes')
-rw-r--r--testes/nextvar.lua29
1 files changed, 14 insertions, 15 deletions
diff --git a/testes/nextvar.lua b/testes/nextvar.lua
index 00e509f8..d1da3cee 100644
--- a/testes/nextvar.lua
+++ b/testes/nextvar.lua
@@ -316,21 +316,6 @@ end
316local a = {} 316local a = {}
317for i=1,lim do a[i] = true; foo(i, table.unpack(a)) end 317for i=1,lim do a[i] = true; foo(i, table.unpack(a)) end
318 318
319
320-- Table length with limit smaller than maximum value at array
321local a = {}
322for i = 1,64 do a[i] = true end -- make its array size 64
323for i = 1,64 do a[i] = nil end -- erase all elements
324assert(T.querytab(a) == 64) -- array part has 64 elements
325a[32] = true; a[48] = true; -- binary search will find these ones
326a[51] = true -- binary search will miss this one
327assert(#a == 48) -- this will set the limit
328assert(select(3, T.querytab(a)) == 48) -- this is the limit now
329a[50] = true -- this will set a new limit
330assert(select(3, T.querytab(a)) == 50) -- this is the limit now
331-- but the size is larger (and still inside the array part)
332assert(#a == 51)
333
334end --] 319end --]
335 320
336 321
@@ -344,6 +329,20 @@ assert(#{1, 2, 3, nil, nil} == 3)
344print'+' 329print'+'
345 330
346 331
332do
333 local s1, s2 = math.randomseed()
334 print(string.format(
335 "testing length for some random tables (seeds 0X%x:%x)", s1, s2))
336 local N = 130
337 for i = 1, 1e3 do -- create that many random tables
338 local a = table.create(math.random(N)) -- initiate with random size
339 for j = 1, math.random(N) do -- add random number of random entries
340 a[math.random(N)] = true
341 end
342 assert(#a == 0 or a[#a] and not a[#a + 1])
343 end
344end
345
347local nofind = {} 346local nofind = {}
348 347
349a,b,c = 1,2,3 348a,b,c = 1,2,3