示例工程 05-variables-and-scope

05-variables-and-scope/02-local-x-equals-x/_test.lua

lua · 0.4 KB

-- @runtimes lua54 luajit
local h = require("harness")
local m = require("main")
 
h.describe("local x = x", function()
	h.it("右侧读外层值", function()
		local result = m.run(function() end)
		h.eq(result.after, 11)
	end)
 
	h.it("没有外层同名变量时读到 nil", function()
		local result = m.run(function() end)
		h.eq(result.fresh_nil, true)
	end)
end)
 
h.run()