aboutsummaryrefslogtreecommitdiff
path: root/testes/code.lua
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--testes/code.lua24
1 files changed, 22 insertions, 2 deletions
diff --git a/testes/code.lua b/testes/code.lua
index 111717ce..380ff70c 100644
--- a/testes/code.lua
+++ b/testes/code.lua
@@ -1,6 +1,8 @@
1-- $Id: testes/code.lua $ 1-- $Id: testes/code.lua $
2-- See Copyright Notice in file lua.h 2-- See Copyright Notice in file lua.h
3 3
4global <const> *
5
4if T==nil then 6if T==nil then
5 (Message or print)('\n >>> testC not active: skipping opcode tests <<<\n') 7 (Message or print)('\n >>> testC not active: skipping opcode tests <<<\n')
6 return 8 return
@@ -405,8 +407,8 @@ do -- tests for table access in upvalues
405end 407end
406 408
407-- de morgan 409-- de morgan
408checkequal(function () local a; if not (a or b) then b=a end end, 410checkequal(function () local a, b; if not (a or b) then b=a end end,
409 function () local a; if (not a and not b) then b=a end end) 411 function () local a, b; if (not a and not b) then b=a end end)
410 412
411checkequal(function (l) local a; return 0 <= a and a <= l end, 413checkequal(function (l) local a; return 0 <= a and a <= l end,
412 function (l) local a; return not (not(a >= 0) or not(a <= l)) end) 414 function (l) local a; return not (not(a >= 0) or not(a <= l)) end)
@@ -480,5 +482,23 @@ do -- basic check for SETLIST
480 assert(count == 1) 482 assert(count == 1)
481end 483end
482 484
485
486do print("testing code for integer limits")
487 local function checkints (n)
488 local source = string.format(
489 "local a = {[true] = 0X%x}; return a[true]", n)
490 local f = assert(load(source))
491 checkKlist(f, {n})
492 assert(f() == n)
493 f = load(string.dump(f))
494 assert(f() == n)
495 end
496
497 checkints(math.maxinteger)
498 checkints(math.mininteger)
499 checkints(-1)
500
501end
502
483print 'OK' 503print 'OK'
484 504