This repository has been archived on 2022-12-23. You can view files and clone it, but cannot push or open issues or pull requests.
fuck-premake-old2/tests/base/test_aliasing.lua
Jason Perkins e84cc11412 Add ability to safely alias function names without breaking overrides
Introduces new calls premake.alias() and premake.resolveAlias()
2015-07-28 17:20:13 -04:00

65 lines
1.4 KiB
Lua

--
-- tests/base/test_aliasing.lua
-- Verify handling of function aliases.
-- Copyright (c) 2015 Jason Perkins and the Premake project
--
local suite = test.declare("premake_alias")
local p = premake
function suite.setup()
suite.testfunc = function()
return 48
end
suite.aliased = nil
suite.aliased2 = nil
end
function suite.returnsOriginalFunction_onNoAlias()
local scope, f = p.resolveAlias(suite, "testfunc")
test.isequal("testfunc", f)
end
function suite.pointsAliasToOriginalFunction()
p.alias(suite, "testfunc", "aliased")
test.isequal(48, suite.aliased())
end
function suite.returnsOriginalFunction_onAlias()
p.alias(suite, "testfunc", "aliased")
local scope, f = p.resolveAlias(suite, "aliased")
test.isequal("testfunc", f)
end
function suite.returnsOriginalFunction_onChainedAliases()
p.alias(suite, "testfunc", "aliased")
p.alias(suite, "aliased", "aliased2")
local scope, f = p.resolveAlias(suite, "aliased2")
test.isequal("testfunc", f)
end
function suite.overrideResolvesAliases()
p.alias(suite, "testfunc", "aliased")
p.override(suite, "aliased", function(base)
return base() + 1
end)
test.isequal(49, suite.testfunc())
end
function suite.aliasTracksOverrides()
p.alias(suite, "testfunc", "aliased")
p.override(suite, "testfunc", function(base)
return base() + 1
end)
test.isequal(49, suite.aliased())
end