aboutsummaryrefslogtreecommitdiff
path: root/testes/sort.lua
diff options
context:
space:
mode:
authorRoberto I <roberto@inf.puc-rio.br>2026-03-09 16:24:49 -0300
committerRoberto I <roberto@inf.puc-rio.br>2026-03-09 16:24:49 -0300
commit377cbea61b2688b21c7d243fc0f42498851df794 (patch)
tree8cb22991c61e8f3644c70f16801e07112c475b2b /testes/sort.lua
parent36d5d2b2847906aa3b66e020d5d894a14ba2bf90 (diff)
downloadlua-377cbea61b2688b21c7d243fc0f42498851df794.tar.gz
lua-377cbea61b2688b21c7d243fc0f42498851df794.tar.bz2
lua-377cbea61b2688b21c7d243fc0f42498851df794.zip
'table.tunpack' using 'aux_getn' like the others
'table.tunpack' was not checking its first argument, which could result in error messages generated inside the API, without location information.
Diffstat (limited to '')
-rw-r--r--testes/sort.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/testes/sort.lua b/testes/sort.lua
index b0127660..92aaca3c 100644
--- a/testes/sort.lua
+++ b/testes/sort.lua
@@ -72,6 +72,19 @@ assert(a==1 and x==nil)
72a,x = unpack({1,2}, 1, 1) 72a,x = unpack({1,2}, 1, 1)
73assert(a==1 and x==nil) 73assert(a==1 and x==nil)
74 74
75
76do -- unpack with non-tables
77 local debug = require"debug"
78 local oldmt = debug.getmetatable(0)
79 local str = "hello"
80 debug.setmetatable(0,
81 { __len = function () return #str end,
82 __index = function (_, i) return string.sub(str, i, i) end})
83 assert(table.concat({table.unpack(0)}) == str)
84 debug.setmetatable(0, oldmt) -- restore original metatable for numbers
85end
86
87
75do 88do
76 local maxi = (1 << 31) - 1 -- maximum value for an int (usually) 89 local maxi = (1 << 31) - 1 -- maximum value for an int (usually)
77 local mini = -(1 << 31) -- minimum value for an int (usually) 90 local mini = -(1 << 31) -- minimum value for an int (usually)