VirtualBox

source: kBuild/trunk/src/kmk/tests/scripts/functions/evalcall

Last change on this file was 2413, checked in by bird, 15 years ago

copyright year update.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 KB
Line 
1# $Id: evalcall 2413 2010-09-11 17:43:04Z bird $ -*-perl-*-
2## @file
3# $(evalcall var,argN...)
4#
5
6#
7# Copyright (c) 2008-2010 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 3 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, see <http://www.gnu.org/licenses/>
23#
24#
25
26$description = "Tests the $(evalcall ) function";
27
28$details = "A few simple tests, nothing spectacular.";
29
30if ($is_kmk) {
31
32 # TEST #0 - check that the feature is present.
33 # --------------------------------------------
34 run_make_test('
35FUNC = local .RETURN = $2 $1
36ifneq ($(evalcall FUNC,a,b),b a)
37$(error sub-test 0 failed: $(evalcall FUNC,a,b))
38endif
39
40.PHONY: all
41all: ; @:
42',
43'',
44'');
45
46 # TEST #1 - the real test.
47 # ------------------------
48 run_make_test('
49
50FUNC = local .RETURN = $2 $1
51ifneq ($(evalcall FUNC,a,b),b a)
52$(error sub-test 0 failed)
53endif
54
55ADD = local .RETURN = $(expr $1 + $2)
56ifneq ($(evalcall ADD,1,2),3)
57$(error sub-test 1 failed)
58endif
59
60define POP
61local words := $(words $($1))
62local .RETURN := $(word $(words), $($1))
63$1 := $(wordlist 1, $(expr $(words) - 1), $($1))
64endef
65stack-var = a b c d
66ifneq ($(evalcall POP,stack-var),d)
67$(error sub-test 2d failed)
68endif
69ifneq ($(evalcall POP,stack-var),c)
70$(error sub-test 2c failed)
71endif
72ifneq ($(evalcall POP,stack-var),b)
73$(error sub-test 2b failed)
74endif
75ifneq ($(evalcall POP,stack-var),a)
76$(error sub-test 2a failed)
77endif
78
79
80# Negative tests:
81
82.RETURN = $2 $1
83FUNC =
84ifneq ($(evalcall FUNC,a,b),)
85$(error sub-test 10 failed)
86endif
87
88.RETURN =
89FUNC = .RETURN = $2 $1
90ifneq ($(evalcall FUNC,a,b),)
91$(error sub-test 11 failed)
92endif
93
94
95# Test .ARGC:
96
97FUNC = local .RETURN = $(.ARGC)
98ifneq ($(evalcall FUNC,a,b),2)
99$(error sub-test 20 failed)
100endif
101ifneq ($(evalcall FUNC),0)
102$(error sub-test 21 failed)
103endif
104ifneq ($(evalcall FUNC,aasdfasdf),1)
105$(error sub-test 22 failed)
106endif
107
108
109.PHONY: all
110all: ; @:
111',
112'',
113'');
114}
115
116
117# Indicate that we're done.
1181;
119
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