Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test_functions.lua « tests - github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1664ea3c7a2d52fb81208906436c4747570618bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
--
-- tests/test_api.lua
-- Automated test suite for the project API.
-- Copyright (c) 2008 Jason Perkins and the Premake project
--


	T.api = { }

	local sln
	function T.api.setup()
		sln = solution "MySolution"
	end
	
	
--
-- solution() tests
--

	function T.api.solution_SetsCurrentObject()
		test.istrue(sln == premake.CurrentContainer)
	end
	
	function T.api.solution_SetsName()
		test.isequal("MySolution", sln.name)
	end
	
	function T.api.solution_SetsLocation()
		test.isequal(os.getcwd(), sln.location)
	end

	function T.api.solution_ReturnsNil_OnNoActiveSolution()
		premake.CurrentContainer = nil
		test.isfalse(solution())
	end
	
	function T.api.solutions_ReturnsSolution_OnActiveProject()
		project("MyProject")
		test.istrue(sln == solution())
	end

	function T.api.solution_OnNewName()
		local sln2 = solution "MySolution2"
		test.isfalse(sln == sln2)
	end

	function T.api.solution_OnExistingName()
		local sln2 = solution "MySolution2"
		test.istrue(sln == solution("MySolution"))
	end



--
-- configuration() tests
--
		
	function T.api.configuration_RaisesError_OnNoContainer()
		premake.CurrentContainer = nil
		local fn = function() configuration{"Debug"} end
		ok, err = pcall(fn)
		test.isfalse(ok)
	end

	function T.api.configuration_SetsCurrentConfiguration()
		sln = solution("MySolution")
		cfg = configuration{"Debug"}
		test.istrue(premake.CurrentConfiguration == cfg)
	end

	function T.api.configuration_AddsToContainer()
		sln = solution("MySolution")
		cfg = configuration{"Debug"}
		test.istrue(cfg == sln.blocks[#sln.blocks])
	end


--
-- project() tests
--
		
	function T.api.project_RaisesError_OnNoSolution()
		premake.CurrentContainer = nil
		local fn = function() project("MyProject") end
		ok, err = pcall(fn)
		test.isfalse(ok)
	end

	function T.api.project_SetsCurrentContainer()
		prj = project("MyProject")
		test.istrue(prj == premake.CurrentContainer)
	end

	function T.api.project_AddsToSolution()
		prj = project("MyProject")
		test.istrue(prj == sln.projects[1])
	end
	
	function T.api.project_SetsName()
		prj = project("MyProject")
		test.isequal("MyProject", prj.name)
	end
	
	function T.api.project_SetsLocation()
		prj = project("MyProject")
		test.isequal(os.getcwd(), prj.location)
	end
	
	function T.api.project_SetsSolution()
		prj = project("MyProject")
		test.istrue(sln == prj.solution)
	end

	function T.api.project_SetsConfiguration()
		prj = project("MyProject")
		test.istrue(premake.CurrentConfiguration == prj.blocks[1])
	end

	function T.api.project_ReturnsNil_OnNoActiveProject()
		test.isfalse(project())
	end

	function T.api.project_OnNewName()
		local prj  = project "MyProject"
		local prj2 = project "MyProject2"
		test.isfalse(prj == prj2)
	end

	function T.api.project_OnExistingName()
		local prj  = project "MyProject"
		local prj2 = project "MyProject2"
		test.istrue(prj == project("MyProject"))
	end

	function T.api.project_SetsUUID()
		local prj = project "MyProject"
		test.istrue(prj.uuid)
	end