Several details in code (e.g., moving a variable to the most inner
scope that encloses its uses), comments, parameter names, extra tests.
This commit is contained in:
Roberto Ierusalimschy
2020-02-27 12:59:22 -03:00
parent 9b7987a9d1
commit 6eb53b7526
13 changed files with 52 additions and 45 deletions

View File

@@ -649,6 +649,11 @@ t = debug.getinfo(1) -- main
assert(t.isvararg == true and t.nparams == 0 and t.nups == 1 and
debug.getupvalue(t.func, 1) == "_ENV")
t = debug.getinfo(math.sin) -- C function
assert(t.isvararg == true and t.nparams == 0 and t.nups == 0)
t = debug.getinfo(string.gmatch("abc", "a")) -- C closure
assert(t.isvararg == true and t.nparams == 0 and t.nups > 0)

View File

@@ -325,6 +325,7 @@ else
assert(u1 == u3 and u3 == u1 and u1 ~= u2)
assert(u2 == u1 and u2 == u3 and u3 == u2)
assert(u2 ~= {}) -- different types cannot be equal
assert(rawequal(u1, u1) and not rawequal(u1, u3))
local mirror = {}
debug.setmetatable(u3, {__index = mirror, __newindex = mirror})

View File

@@ -960,7 +960,10 @@ do
aux(-10,0)
aux(1, 6)
aux(1, 2)
aux(1, 13)
aux(1, 31)
aux(1, 32)
aux(1, 33)
aux(-10, 10)
aux(-10,-10) -- unit set
aux(minint, minint) -- unit set
@@ -998,6 +1001,7 @@ do
end
aux(0, maxint)
aux(1, maxint)
aux(3, maxint // 3)
aux(minint, -1)
aux(minint // 2, maxint // 2)
aux(minint, maxint)

View File

@@ -76,7 +76,7 @@ end
-- testing constructor sizes
local sizes = {0, 1, 2, 3, 4, 5, 7, 8, 9, 15, 16, 17,
30, 31, 32, 33, 34, 500, 1000}
30, 31, 32, 33, 34, 254, 255, 256, 500, 1000}
for _, sa in ipairs(sizes) do -- 'sa' is size of the array part
local arr = {"return {"}