diff --git a/README.html b/README.html index 567b328c..fe74cff1 100644 --- a/README.html +++ b/README.html @@ -743,5 +743,6 @@ and LuaForge:
  • module() and setfenv() only partially supported for lau2java or luajc compiled lua
  • values associated with weak keys may linger longer than expected
  • behavior of luaj when a SecurityManager is used has not been fully characterized +
  • Negative zero is treated as identical to integer value zero throughout luaj diff --git a/src/core/org/luaj/vm2/compiler/LexState.java b/src/core/org/luaj/vm2/compiler/LexState.java index 26cb6216..677b73d8 100644 --- a/src/core/org/luaj/vm2/compiler/LexState.java +++ b/src/core/org/luaj/vm2/compiler/LexState.java @@ -417,7 +417,7 @@ public class LexState { LuaC._assert (isdigit(current)); save_and_next(); if (first == '0' && check_next("Xx")) - expo = "PpEe"; + expo = "Pp"; while (true) { if (check_next(expo)) check_next("+-"); diff --git a/test/lua/luaj3.0-tests.zip b/test/lua/luaj3.0-tests.zip index 61dd82b5..3975d417 100644 Binary files a/test/lua/luaj3.0-tests.zip and b/test/lua/luaj3.0-tests.zip differ diff --git a/test/lua/mathlib.lua b/test/lua/mathlib.lua index b23f8ffe..9ed3ac3c 100644 --- a/test/lua/mathlib.lua +++ b/test/lua/mathlib.lua @@ -218,4 +218,23 @@ print( math.randomseed(20) ) for i=1,20 do print( t[i] == math.random() ) 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) + --]]