2012-10-19 22:53:03 +00:00
|
|
|
--
|
|
|
|
-- tests/base/test_context.lua
|
|
|
|
-- Test suite for the configuration context API.
|
|
|
|
-- Copyright (c) 2012 Jason Perkins and the Premake project
|
|
|
|
--
|
|
|
|
|
|
|
|
T.context = {}
|
|
|
|
local suite = T.context
|
|
|
|
|
|
|
|
local context = premake.context
|
|
|
|
local configset = premake.configset
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Setup and teardown
|
|
|
|
--
|
|
|
|
|
|
|
|
local ctx, cfgset
|
|
|
|
|
|
|
|
function suite.setup()
|
|
|
|
cfgset = configset.new()
|
2012-11-04 14:21:58 +00:00
|
|
|
ctx = context.new(cfgset)
|
2012-10-19 22:53:03 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Make sure that new() returns a valid object.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.new_returnsValidObject()
|
|
|
|
test.isequal("table", type(ctx))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Context should be able to retrieve a default value from
|
|
|
|
-- the configuration set, using the field name.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.returnsConfigValue_onExistingValue()
|
2012-11-04 14:21:58 +00:00
|
|
|
cfgset.targetextension = ".so"
|
2012-10-19 22:53:03 +00:00
|
|
|
test.isequal(".so", ctx.targetextension)
|
|
|
|
end
|
2012-11-04 14:21:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Tokens encountered in enabled fields should be expanded.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.doesExpandTokens()
|
|
|
|
cfgset.targetname = "MyProject%{1 + 1}"
|
|
|
|
test.isequal("MyProject2", ctx.targetname)
|
|
|
|
end
|