Document current behavior of negative zero.
This commit is contained in:
@@ -743,5 +743,6 @@ and LuaForge:
|
|||||||
<li>module() and setfenv() only partially supported for lau2java or luajc compiled lua
|
<li>module() and setfenv() only partially supported for lau2java or luajc compiled lua
|
||||||
<li>values associated with weak keys may linger longer than expected
|
<li>values associated with weak keys may linger longer than expected
|
||||||
<li>behavior of luaj when a SecurityManager is used has not been fully characterized
|
<li>behavior of luaj when a SecurityManager is used has not been fully characterized
|
||||||
|
<li>Negative zero is treated as identical to integer value zero throughout luaj
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|||||||
@@ -417,7 +417,7 @@ public class LexState {
|
|||||||
LuaC._assert (isdigit(current));
|
LuaC._assert (isdigit(current));
|
||||||
save_and_next();
|
save_and_next();
|
||||||
if (first == '0' && check_next("Xx"))
|
if (first == '0' && check_next("Xx"))
|
||||||
expo = "PpEe";
|
expo = "Pp";
|
||||||
while (true) {
|
while (true) {
|
||||||
if (check_next(expo))
|
if (check_next(expo))
|
||||||
check_next("+-");
|
check_next("+-");
|
||||||
|
|||||||
Binary file not shown.
@@ -218,4 +218,23 @@ print( math.randomseed(20) )
|
|||||||
for i=1,20 do
|
for i=1,20 do
|
||||||
print( t[i] == math.random() )
|
print( t[i] == math.random() )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- tests involving -0, which is folded into 0 for luaj, but not for plain lua
|
||||||
|
print("----------- Tests involving -0 and NaN")
|
||||||
|
print('0 == -0', 0 == -0)
|
||||||
|
t = {[0] = 10, 20, 30, 40, 50}
|
||||||
|
print('t[-0] == t[0]',t[-0] == t[0])
|
||||||
|
local x = -1
|
||||||
|
local mz, z = 0/x, 0 -- minus zero, zero
|
||||||
|
print('mz, z', mz, z)
|
||||||
|
print('mz == z', mz == z)
|
||||||
|
print('1/mz < 0 and 0 < 1/z', 1/mz < 0 and 0 < 1/z)
|
||||||
|
local a = {[mz] = 1}
|
||||||
|
print('a[z] == 1 and a[mz] == 1', a[z] == 1 and a[mz] == 1)
|
||||||
|
-- string with same binary representation as 0.0 (may create problems
|
||||||
|
-- for constant manipulation in the pre-compiler)
|
||||||
|
local a1, a2, a3, a4, a5 = 0, 0, "\0\0\0\0\0\0\0\0", 0, "\0\0\0\0\0\0\0\0"
|
||||||
|
assert(a1 == a2 and a2 == a4 and a1 ~= a3)
|
||||||
|
assert(a3 == a5)
|
||||||
|
|
||||||
--]]
|
--]]
|
||||||
|
|||||||
Reference in New Issue
Block a user