Re: Parenless calls for function literals

"'Sainan' via lua-l" <[email protected]> Thu, 28 May 2026 18:30:24 +0000
Newsgroups gmane.comp.lang.lua.general
Message-ID <5_zubAUqG3RfuCogzimwVGSsVu8RAxUr_HfrZI0ethrThCntGUqJAYJy8zJSvwJPdkY1ajG9zgQCzyiRHAJVToXZZX5TIrEab1H0PZrnx_U=@calamity.inc>
My 2 cents:

-- Test library
local units = {}
local unit_currently_describing
__atexit = setmetatable({}, {
    __gc = function()
        for unit_name, unit in pairs(units) do
            for test_name, test in pairs(unit) do
                local ok, msg = pcall(test)
                if not ok then
                    print("Test failure in " .. unit_name .. "'s test \"" .. test_name .. "\": " .. msg)
                end
            end
        end
    end
})
function describe(name)
    units[name] = {}
    unit_currently_describing = name
end
function it(name, func)
    units[unit_currently_describing][name] = func
end

-- Test code
describe "Foo" do
    it("1 is true", function()
        assert(1)
    end)
end
describe "Bar" do
    it("0 is true", function()
        assert(0)
    end)
end

-- Sainan

-- 
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/lua-l/5_zubAUqG3RfuCogzimwVGSsVu8RAxUr_HfrZI0ethrThCntGUqJAYJy8zJSvwJPdkY1ajG9zgQCzyiRHAJVToXZZX5TIrEab1H0PZrnx_U%3D%40calamity.inc.