math_spec.lua 477 B

12345678910111213141516
  1. _G.core = {}
  2. dofile("builtin/common/math.lua")
  3. describe("math", function()
  4. it("round()", function()
  5. assert.equal(0, math.round(0))
  6. assert.equal(10, math.round(10.3))
  7. assert.equal(11, math.round(10.5))
  8. assert.equal(11, math.round(10.7))
  9. assert.equal(-10, math.round(-10.3))
  10. assert.equal(-11, math.round(-10.5))
  11. assert.equal(-11, math.round(-10.7))
  12. assert.equal(0, math.round(0.49999999999999994))
  13. assert.equal(0, math.round(-0.49999999999999994))
  14. end)
  15. end)