diff options
| author | Roberto I <roberto@inf.puc-rio.br> | 2026-03-09 16:24:49 -0300 |
|---|---|---|
| committer | Roberto I <roberto@inf.puc-rio.br> | 2026-03-09 16:24:49 -0300 |
| commit | 377cbea61b2688b21c7d243fc0f42498851df794 (patch) | |
| tree | 8cb22991c61e8f3644c70f16801e07112c475b2b /testes/sort.lua | |
| parent | 36d5d2b2847906aa3b66e020d5d894a14ba2bf90 (diff) | |
| download | lua-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 'testes/sort.lua')
| -rw-r--r-- | testes/sort.lua | 13 |
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) | |||
| 72 | a,x = unpack({1,2}, 1, 1) | 72 | a,x = unpack({1,2}, 1, 1) |
| 73 | assert(a==1 and x==nil) | 73 | assert(a==1 and x==nil) |
| 74 | 74 | ||
| 75 | |||
| 76 | do -- 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 | ||
| 85 | end | ||
| 86 | |||
| 87 | |||
| 75 | do | 88 | do |
| 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) |
