2024-04-09 04:26:16 -07:00
|
|
|
local t = require('test.functional.testutil')()
|
2024-04-08 02:03:20 -07:00
|
|
|
local eq = t.eq
|
|
|
|
local eval = t.eval
|
|
|
|
local clear = t.clear
|
2015-12-25 15:18:14 -07:00
|
|
|
|
|
|
|
describe('Division operator', function()
|
|
|
|
before_each(clear)
|
|
|
|
|
|
|
|
it('returns infinity on {positive}/0.0', function()
|
|
|
|
eq("str2float('inf')", eval('string(1.0/0.0)'))
|
|
|
|
eq("str2float('inf')", eval('string(1.0e-100/0.0)'))
|
|
|
|
eq("str2float('inf')", eval('string(1.0e+100/0.0)'))
|
|
|
|
eq("str2float('inf')", eval('string((1.0/0.0)/0.0)'))
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('returns -infinity on {negative}/0.0', function()
|
|
|
|
eq("-str2float('inf')", eval('string((-1.0)/0.0)'))
|
|
|
|
eq("-str2float('inf')", eval('string((-1.0e-100)/0.0)'))
|
|
|
|
eq("-str2float('inf')", eval('string((-1.0e+100)/0.0)'))
|
|
|
|
eq("-str2float('inf')", eval('string((-1.0/0.0)/0.0)'))
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('returns NaN on 0.0/0.0', function()
|
|
|
|
eq("str2float('nan')", eval('string(0.0/0.0)'))
|
|
|
|
eq("str2float('nan')", eval('string(-(0.0/0.0))'))
|
|
|
|
eq("str2float('nan')", eval('string((-0.0)/0.0)'))
|
|
|
|
end)
|
|
|
|
end)
|