示例工程 03-numbers

03-numbers/02-floor-division-negatives/_test.lua

lua · 0.4 KB

-- @runtimes lua54
local h = require("harness")
local m = require("main")
 
h.describe("负数整除", function()
	h.it("向下取整而不是截断", function()
		local result = m.run(function() end)
		h.eq(result.div, -4)
		h.eq(result.mod, 1)
	end)
 
	h.it("fmod 保持 C 的符号", function()
		local result = m.run(function() end)
		h.eq(result.fmod, -1)
	end)
end)
 
h.run()