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/api/test_boolean_kind.lua

81 lines
1.3 KiB
Lua
Raw Normal View History

2014-10-18 20:06:04 +00:00
--
-- tests/api/test_boolean_kind.lua
-- Tests the boolean API value type.
-- Copyright (c) 2014 Jason Perkins and the Premake project
--
2017-04-25 05:44:13 +00:00
local p = premake
2014-10-18 20:06:04 +00:00
local suite = test.declare("api_boolean_kind")
2017-04-25 05:44:13 +00:00
local api = p.api
2014-10-18 20:06:04 +00:00
--
-- Setup and teardown
--
function suite.setup()
api.register {
name = "testapi",
kind = "boolean",
scope = "project",
}
2015-08-28 20:16:14 +00:00
test.createWorkspace()
2014-10-18 20:06:04 +00:00
end
function suite.teardown()
testapi = nil
end
--
-- Check setting of true values.
--
function suite.setsTrue_onYes()
testapi "yes"
test.istrue(api.scope.project.testapi)
end
function suite.setsTrue_onBooleanTrue()
testapi (true)
test.istrue(api.scope.project.testapi)
end
function suite.setsTrue_onNonZero()
testapi (1)
test.istrue(api.scope.project.testapi)
end
--
-- Check setting of false values.
--
function suite.setsFalse_onNo()
testapi "no"
test.isfalse(api.scope.project.testapi)
end
function suite.setsFalse_onBooleanFalse()
testapi (false)
test.isfalse(api.scope.project.testapi)
end
function suite.setsFalse_onZero()
testapi (0)
test.isfalse(api.scope.project.testapi)
end
--
-- Raise an error on an invalid string value.
--
function suite.raisesError_onDisallowedValue()
ok, err = pcall(function ()
testapi "maybe"
end)
test.isfalse(ok)
end