diff options
Diffstat (limited to 'testes/nextvar.lua')
-rw-r--r-- | testes/nextvar.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/testes/nextvar.lua b/testes/nextvar.lua index 076f6361..9e23e572 100644 --- a/testes/nextvar.lua +++ b/testes/nextvar.lua | |||
@@ -43,6 +43,14 @@ assert(i == 4) | |||
43 | assert(type(ipairs{}) == 'function' and ipairs{} == ipairs{}) | 43 | assert(type(ipairs{}) == 'function' and ipairs{} == ipairs{}) |
44 | 44 | ||
45 | 45 | ||
46 | do -- overflow (must wrap-around) | ||
47 | local f = ipairs{} | ||
48 | local k, v = f({[math.mininteger] = 10}, math.maxinteger) | ||
49 | assert(k == math.mininteger and v == 10) | ||
50 | k, v = f({[math.mininteger] = 10}, k) | ||
51 | assert(k == nil) | ||
52 | end | ||
53 | |||
46 | if not T then | 54 | if not T then |
47 | (Message or print) | 55 | (Message or print) |
48 | ('\n >>> testC not active: skipping tests for table sizes <<<\n') | 56 | ('\n >>> testC not active: skipping tests for table sizes <<<\n') |
@@ -499,6 +507,15 @@ do -- testing table library with metamethods | |||
499 | end | 507 | end |
500 | 508 | ||
501 | 509 | ||
510 | do -- testing overflow in table.insert (must wrap-around) | ||
511 | |||
512 | local t = setmetatable({}, | ||
513 | {__len = function () return math.maxinteger end}) | ||
514 | table.insert(t, 20) | ||
515 | local k, v = next(t) | ||
516 | assert(k == math.mininteger and v == 20) | ||
517 | end | ||
518 | |||
502 | if not T then | 519 | if not T then |
503 | (Message or print) | 520 | (Message or print) |
504 | ('\n >>> testC not active: skipping tests for table library on non-tables <<<\n') | 521 | ('\n >>> testC not active: skipping tests for table library on non-tables <<<\n') |