VirtualBox

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

Last change on this file since 2158 was 2158, checked in by bird, 16 years ago

kmk: Extended evalcall and evalcall2 with a return value, local .RETURN.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 KB
Line 
1# $Id: evalcall 2158 2008-12-29 15:43:31Z bird $ -*-perl-*-
2## @file
3# $(evalcall var,argN...)
4#
5
6#
7# Copyright (c) 2008 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# negative tests:
80
81.RETURN = $2 $1
82FUNC =
83ifneq ($(evalcall FUNC,a,b),)
84$(error sub-test 10 failed)
85endif
86
87.RETURN =
88FUNC = .RETURN = $2 $1
89ifneq ($(evalcall FUNC,a,b),)
90$(error sub-test 11 failed)
91endif
92
93.PHONY: all
94all: ; @:
95',
96'',
97'');
98}
99
100
101
102# Indicate that we're done.
1031;
104
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