示例工程 06-control-flow-and-truthiness

06-control-flow-and-truthiness/03-and-or-returns-operand/_test.lua

lua · 0.4 KB

-- @runtimes lua54 luajit
local h = require("harness")
local m = require("main")
 
h.describe("and/or 返回值", function()
	h.it("or 保留真值左操作数", function()
		local result = m.run(function() end)
		h.eq(result.value, 0)
		h.eq(result.fallback, "default")
	end)
 
	h.it("and 返回最后一个真值", function()
		local result = m.run(function() end)
		h.eq(result.chained, "b")
	end)
end)
 
h.run()