diff options
Diffstat (limited to 'testes/math.lua')
| -rw-r--r-- | testes/math.lua | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/testes/math.lua b/testes/math.lua index c45a91ad..befce12e 100644 --- a/testes/math.lua +++ b/testes/math.lua | |||
| @@ -270,7 +270,7 @@ else | |||
| 270 | end | 270 | end |
| 271 | 271 | ||
| 272 | do | 272 | do |
| 273 | local NaN = 0/0 | 273 | local <const> NaN = 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,7 +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 mz, z = -0.0, 0.0 | 770 | local <const> mz = -0.0 |
| 771 | local <const> z = 0.0 | ||
| 771 | assert(mz == z) | 772 | assert(mz == z) |
| 772 | assert(1/mz < 0 and 0 < 1/z) | 773 | assert(1/mz < 0 and 0 < 1/z) |
| 773 | local a = {[mz] = 1} | 774 | local a = {[mz] = 1} |
| @@ -775,17 +776,18 @@ do | |||
| 775 | a[z] = 2 | 776 | a[z] = 2 |
| 776 | assert(a[z] == 2 and a[mz] == 2) | 777 | assert(a[z] == 2 and a[mz] == 2) |
| 777 | local inf = math.huge * 2 + 1 | 778 | local inf = math.huge * 2 + 1 |
| 778 | mz, z = -1/inf, 1/inf | 779 | local <const> mz = -1/inf |
| 780 | local <const> z = 1/inf | ||
| 779 | assert(mz == z) | 781 | assert(mz == z) |
| 780 | assert(1/mz < 0 and 0 < 1/z) | 782 | assert(1/mz < 0 and 0 < 1/z) |
| 781 | local NaN = inf - inf | 783 | local <const> NaN = inf - inf |
| 782 | assert(NaN ~= NaN) | 784 | assert(NaN ~= NaN) |
| 783 | assert(not (NaN < NaN)) | 785 | assert(not (NaN < NaN)) |
| 784 | assert(not (NaN <= NaN)) | 786 | assert(not (NaN <= NaN)) |
| 785 | assert(not (NaN > NaN)) | 787 | assert(not (NaN > NaN)) |
| 786 | assert(not (NaN >= NaN)) | 788 | assert(not (NaN >= NaN)) |
| 787 | assert(not (0 < NaN) and not (NaN < 0)) | 789 | assert(not (0 < NaN) and not (NaN < 0)) |
| 788 | local NaN1 = 0/0 | 790 | local <const> NaN1 = 0/0 |
| 789 | assert(NaN ~= NaN1 and not (NaN <= NaN1) and not (NaN1 <= NaN)) | 791 | assert(NaN ~= NaN1 and not (NaN <= NaN1) and not (NaN1 <= NaN)) |
| 790 | local a = {} | 792 | local a = {} |
| 791 | assert(not pcall(rawset, a, NaN, 1)) | 793 | assert(not pcall(rawset, a, NaN, 1)) |
| @@ -814,8 +816,8 @@ end | |||
| 814 | -- the first call after seed 1007 should return 0x7a7040a5a323c9d6 | 816 | -- the first call after seed 1007 should return 0x7a7040a5a323c9d6 |
| 815 | do | 817 | do |
| 816 | -- all computations assume at most 32-bit integers | 818 | -- all computations assume at most 32-bit integers |
| 817 | local h = 0x7a7040a5 -- higher half | 819 | local <const> h = 0x7a7040a5 -- higher half |
| 818 | local l = 0xa323c9d6 -- lower half | 820 | local <const> l = 0xa323c9d6 -- lower half |
| 819 | 821 | ||
| 820 | math.randomseed(1007) | 822 | math.randomseed(1007) |
| 821 | -- get the low 'intbits' of the 64-bit expected result | 823 | -- get the low 'intbits' of the 64-bit expected result |
