Add a test for 0-a as well

0-a can't be simplified with -a as 0 becomes -0 under negation.
This commit is contained in:
Arseny Kapoulkine 2024-11-27 11:18:33 +09:00
parent d83ff5a8bd
commit 0daedcdb9b

View file

@ -96,6 +96,7 @@ assert((function() local a = 1 a = a / 2 return a end)() == 0.5)
-- argument is passed into anonymous function to prevent constant folding
assert((function(a) return tostring(a + 0) end)(-0) == "0")
assert((function(a) return tostring(a - 0) end)(-0) == "-0")
assert((function(a) return tostring(0 - a) end)(0) == "0")
assert((function(a) return tostring(a - a) end)(1 / 0) == "nan")
assert((function(a) return tostring(a * 0) end)(0 / 0) == "nan")
assert((function(a) return tostring(a / (2^1000)) end)(2^1000) == "1")