neovim/test/functional/eval/operators_spec.lua
ZyX ff470bb853 functests: Check logs in lua code
It is otherwise impossible to determine which test failed sanitizer/valgrind
check. test/functional/helpers.lua module return was changed so that tests which
do not provide after_each function to get new check will automatically fail.
2016-06-10 21:50:49 +03:00

29 lines
1.0 KiB
Lua

local helpers = require('test.functional.helpers')(after_each)
local eq = helpers.eq
local eval = helpers.eval
local clear = helpers.clear
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)