2012-04-06 00:02:53 +00:00
|
|
|
--
|
2014-02-27 22:40:25 +00:00
|
|
|
-- tests/api/test_table_kind.lua
|
|
|
|
-- Tests the table API value type.
|
|
|
|
-- Copyright (c) 2012-2014 Jason Perkins and the Premake project
|
2012-04-06 00:02:53 +00:00
|
|
|
--
|
|
|
|
|
2017-04-25 05:44:13 +00:00
|
|
|
local p = premake
|
2014-02-27 22:40:25 +00:00
|
|
|
local suite = test.declare("api_table_kind")
|
2017-04-25 05:44:13 +00:00
|
|
|
local api = p.api
|
2012-04-06 00:02:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Setup and teardown
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.setup()
|
2014-02-27 22:40:25 +00:00
|
|
|
api.register { name = "testapi", kind = "table", scope = "project" }
|
2015-08-28 20:16:14 +00:00
|
|
|
test.createWorkspace()
|
2012-04-06 00:02:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.teardown()
|
|
|
|
testapi = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Array values should be stored as-is.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.storesTable_onArrayValue()
|
|
|
|
testapi { "one", "two" }
|
|
|
|
test.isequal({ "one", "two" }, api.scope.project.testapi)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- String values should be converted into a table.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.storesTable_onStringValue()
|
|
|
|
testapi "myvalue"
|
|
|
|
test.isequal({ "myvalue" }, api.scope.project.testapi)
|
|
|
|
end
|
|
|
|
|
2012-04-10 21:21:37 +00:00
|
|
|
|
2014-02-27 22:40:25 +00:00
|
|
|
--
|
2012-04-10 21:21:37 +00:00
|
|
|
-- New values should overwrite old.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.overwrites_onNewValue()
|
|
|
|
testapi "first"
|
|
|
|
testapi "second"
|
|
|
|
test.isequal({ "second" }, api.scope.project.testapi)
|
|
|
|
end
|