diff options
Diffstat (limited to 'testes/math.lua')
-rw-r--r-- | testes/math.lua | 24 |
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 | ||
4 | print("testing numbers and math lib") | 4 | print("testing numbers and math lib") |
5 | 5 | ||
6 | local <const> minint = math.mininteger | 6 | local minint <const> = math.mininteger |
7 | local <const> maxint = math.maxinteger | 7 | local maxint <const> = math.maxinteger |
8 | 8 | ||
9 | local <const> intbits = math.floor(math.log(maxint, 2) + 0.5) + 1 | 9 | local intbits <const> = math.floor(math.log(maxint, 2) + 0.5) + 1 |
10 | assert((1 << intbits) == 0) | 10 | assert((1 << intbits) == 0) |
11 | 11 | ||
12 | assert(minint == 1 << (intbits - 1)) | 12 | assert(minint == 1 << (intbits - 1)) |
@@ -270,7 +270,7 @@ else | |||
270 | end | 270 | end |
271 | 271 | ||
272 | do | 272 | do |
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 | ||
768 | do | 768 | do |
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 |
817 | do | 817 | do |
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 |