VirtualBox

source: kBuild/trunk/src/kmk/testcase-ifcond.kmk@ 1727

Last change on this file since 1727 was 1727, checked in by bird, 17 years ago

kmk: Two new functions $(if-expr cond,exp-on-true,exp-on-false) and $(expr expression) that uses the expreval.c expression evaluator.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1# $Id: testcase-ifcond.kmk 1727 2008-09-05 01:45:52Z bird $
2## @file
3# kBuild - testcase for the if conditionals.
4#
5
6#
7# Copyright (c) 2007 knut st. osmundsen <[email protected]>
8#
9# This file is part of kBuild.
10#
11# kBuild is free software; you can redistribute it and/or modify
12# it under the terms of the GNU General Public License as published by
13# the Free Software Foundation; either version 2 of the License, or
14# (at your option) any later version.
15#
16# kBuild is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19# GNU General Public License for more details.
20#
21# You should have received a copy of the GNU General Public License
22# along with kBuild; if not, write to the Free Software
23# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24#
25#
26
27
28DEPTH = ../..
29include $(KBUILD_PATH)/header.kmk
30
31ifeq (1,0)
32#
33# Some very basic tests.
34#
35if 1
36$(warning works)
37else
38$(error busted)
39endif
40
41if 1 || 1
42$(warning works)
43else
44$(error )
45endif
46
47if 0 || 0
48$(error )
49else
50$(warning works)
51endif
52
53if 1 || 0
54$(warning works)
55else
56$(error )
57endif
58
59if 0 || 1
60$(warning works)
61else
62$(error )
63endif
64
65if 0 || 0 || 0 || 0 || 0 || 0 || 0
66$(error )
67else
68$(warning works)
69endif
70
71if 0 || 0 || 0 || 1 || 0 || 0 || 0
72$(warning works)
73else
74$(error )
75endif
76
77if 0 && 1
78$(error )
79else
80$(warning works)
81endif
82
83if 0 || 1 && 1
84$(warning works)
85else
86$(error )
87endif
88endif # all
89
90#
91# Parenthesis
92#
93if (1)
94$(warning works)
95else
96$(error )
97endif
98
99if ((((1))))
100$(warning works)
101else
102$(error )
103endif
104
105
106#
107# Equal and Not Equal.
108#
109if 1 == 1
110$(warning works)
111else
112$(error )
113endif
114
115if 2 == 3
116$(error )
117else
118$(warning works)
119endif
120
121if 2 != 3
122$(warning works)
123else
124$(error )
125endif
126
127
128#
129# XOR
130#
131if 1 ^ 1
132$(error )
133else
134$(warning works)
135endif
136
137if 2 ^ 1 == 3
138$(warning works)
139else
140$(error )
141endif
142
143if 7 == 2 ^ 1 ^ 4
144$(warning works)
145else
146$(error )
147endif
148
149
150#
151# Logical NOT
152#
153if !1
154$(error )
155else
156$(warning works)
157endif
158
159if !42 == 0
160$(warning works)
161else
162$(error )
163endif
164
165if !0 == 1
166$(warning works)
167else
168$(error )
169endif
170
171if !!0 == 0
172$(warning works)
173else
174$(error )
175endif
176
177
178#
179# Greater than
180#
181if 1 > 0
182$(warning works)
183else
184$(error )
185endif
186
187if 1024 > 1023
188$(warning works)
189else
190$(error )
191endif
192
193if 999 > 1023
194$(error )
195else
196$(warning works)
197endif
198
199
200#
201# Greater or equal than
202#
203if 20 > 0
204$(warning works)
205else
206$(error )
207endif
208
209if 20 >= 20
210$(warning works)
211else
212$(error )
213endif
214
215if 19 >= 20
216$(error )
217else
218$(warning works)
219endif
220
221
222#
223# target()
224#
225if 0
226trg_deps_only: foobar
227trg_with_cmds: foobar
228 echo $@
229
230if target trg_with_cmds
231$(warning works)
232else
233$(error target)
234endif
235
236if target trg_deps_only
237$(error target)
238else
239$(warning works)
240endif
241
242if target foobar
243$(error target)
244else
245$(warning works)
246endif
247endif
248
249
250#
251# defined()
252#
253var_defined := 1
254var_not_defined :=
255
256if defined var_defined
257$(warning works)
258else
259$(error )
260endif
261
262if defined(var_defined)
263$(warning works)
264else
265$(error )
266endif
267
268if defined (var_defined)
269$(warning works)
270else
271$(error )
272endif
273
274if defined (var_not_defined)
275$(error )
276else
277$(warning works)
278endif
279
280
281#
282# Quick check of $(if-expr ) and $(expr ).
283#
284ifeq ($(if-expr 0 || 2,42,500),42)
285$(warning if-expr test 1 succeeded)
286else
287$(error )
288endif
289
290ifeq ($(if-expr 5+3 == 231,42,500),42)
291$(error )
292else
293$(warning if-expr test 2 succeeded)
294endif
295
296ifeq ($(expr 5+3),8)
297$(warning expr test 1 succeeded)
298else
299$(error expr:$(expr 5+3) expected 8)
300endif
301
302ifeq ($(expr 25*25),625)
303$(warning expr test 2 succeeded)
304else
305$(error expr:$(expr 25*25) expected 625)
306endif
307
308ifeq ($(expr 100/3),3)
309$(error )
310else
311$(warning expr test 3 succeeded)
312endif
313
314
315
316all_recursive:
317 $(ECHO) "if works fine"
318
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette