aboutsummaryrefslogtreecommitdiff
path: root/testes/math.lua
diff options
context:
space:
mode:
Diffstat (limited to 'testes/math.lua')
-rw-r--r--testes/math.lua24
1 files changed, 12 insertions, 12 deletions
diff --git a/testes/math.lua b/testes/math.lua
index d0aaa6a5..bad43901 100644
--- a/testes/math.lua
+++ b/testes/math.lua
@@ -3,10 +3,10 @@
3 3
4print("testing numbers and math lib") 4print("testing numbers and math lib")
5 5
6local <const> minint = math.mininteger 6local minint <const> = math.mininteger
7local <const> maxint = math.maxinteger 7local maxint <const> = math.maxinteger
8 8
9local <const> intbits = math.floor(math.log(maxint, 2) + 0.5) + 1 9local intbits <const> = math.floor(math.log(maxint, 2) + 0.5) + 1
10assert((1 << intbits) == 0) 10assert((1 << intbits) == 0)
11 11
12assert(minint == 1 << (intbits - 1)) 12assert(minint == 1 << (intbits - 1))
@@ -270,7 +270,7 @@ else
270end 270end
271 271
272do 272do
273 local <const> NaN = 0/0 273 local NaN <const> = 0/0
274 assert(not (NaN < 0)) 274 assert(not (NaN < 0))
275 assert(not (NaN > minint)) 275 assert(not (NaN > minint))
276 assert(not (NaN <= -9)) 276 assert(not (NaN <= -9))
@@ -767,8 +767,8 @@ assert(a == '10' and b == '20')
767 767
768do 768do
769 print("testing -0 and NaN") 769 print("testing -0 and NaN")
770 local <const> mz = -0.0 770 local mz <const> = -0.0
771 local <const> z = 0.0 771 local z <const> = 0.0
772 assert(mz == z) 772 assert(mz == z)
773 assert(1/mz < 0 and 0 < 1/z) 773 assert(1/mz < 0 and 0 < 1/z)
774 local a = {[mz] = 1} 774 local a = {[mz] = 1}
@@ -776,18 +776,18 @@ do
776 a[z] = 2 776 a[z] = 2
777 assert(a[z] == 2 and a[mz] == 2) 777 assert(a[z] == 2 and a[mz] == 2)
778 local inf = math.huge * 2 + 1 778 local inf = math.huge * 2 + 1
779 local <const> mz = -1/inf 779 local mz <const> = -1/inf
780 local <const> z = 1/inf 780 local z <const> = 1/inf
781 assert(mz == z) 781 assert(mz == z)
782 assert(1/mz < 0 and 0 < 1/z) 782 assert(1/mz < 0 and 0 < 1/z)
783 local <const> NaN = inf - inf 783 local NaN <const> = inf - inf
784 assert(NaN ~= NaN) 784 assert(NaN ~= NaN)
785 assert(not (NaN < NaN)) 785 assert(not (NaN < NaN))
786 assert(not (NaN <= NaN)) 786 assert(not (NaN <= NaN))
787 assert(not (NaN > NaN)) 787 assert(not (NaN > NaN))
788 assert(not (NaN >= NaN)) 788 assert(not (NaN >= NaN))
789 assert(not (0 < NaN) and not (NaN < 0)) 789 assert(not (0 < NaN) and not (NaN < 0))
790 local <const> NaN1 = 0/0 790 local NaN1 <const> = 0/0
791 assert(NaN ~= NaN1 and not (NaN <= NaN1) and not (NaN1 <= NaN)) 791 assert(NaN ~= NaN1 and not (NaN <= NaN1) and not (NaN1 <= NaN))
792 local a = {} 792 local a = {}
793 assert(not pcall(rawset, a, NaN, 1)) 793 assert(not pcall(rawset, a, NaN, 1))
@@ -816,8 +816,8 @@ end
816-- the first call after seed 1007 should return 0x7a7040a5a323c9d6 816-- the first call after seed 1007 should return 0x7a7040a5a323c9d6
817do 817do
818 -- all computations should work with 32-bit integers 818 -- all computations should work with 32-bit integers
819 local <const> h = 0x7a7040a5 -- higher half 819 local h <const> = 0x7a7040a5 -- higher half
820 local <const> l = 0xa323c9d6 -- lower half 820 local l <const> = 0xa323c9d6 -- lower half
821 821
822 math.randomseed(1007) 822 math.randomseed(1007)
823 -- get the low 'intbits' of the 64-bit expected result 823 -- get the low 'intbits' of the 64-bit expected result