diff options
Diffstat (limited to 'testes')
| -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) |
