| 1 | # $Id: while 2413 2010-09-11 17:43:04Z bird $ -*-perl-*-
|
|---|
| 2 | ## @file
|
|---|
| 3 | # $(while condition,body)
|
|---|
| 4 | #
|
|---|
| 5 |
|
|---|
| 6 | #
|
|---|
| 7 | # Copyright (c) 2008-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
|
|---|
| 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 $(while ) loop function";
|
|---|
| 27 |
|
|---|
| 28 | $details = "A few simple tests, nothing spectacular.";
|
|---|
| 29 |
|
|---|
| 30 | if ($is_kmk) {
|
|---|
| 31 |
|
|---|
| 32 | # TEST #0 - check that the feature is present.
|
|---|
| 33 | # --------------------------------------------
|
|---|
| 34 | run_make_test('
|
|---|
| 35 | VAR := 0
|
|---|
| 36 | OUTPUT := $(while $(VAR)==0,$(eval VAR=1)works)
|
|---|
| 37 | ifneq ($(OUTPUT),works)
|
|---|
| 38 | $(error sub-test 0 failed:$(OUTPUT))
|
|---|
| 39 | endif
|
|---|
| 40 |
|
|---|
| 41 | .PHONY: all
|
|---|
| 42 | all: ; @:
|
|---|
| 43 | ',
|
|---|
| 44 | '',
|
|---|
| 45 | '');
|
|---|
| 46 |
|
|---|
| 47 | # TEST #1 - the real test.
|
|---|
| 48 | # ------------------------
|
|---|
| 49 | run_make_test('
|
|---|
| 50 | VAR := 0
|
|---|
| 51 | OUTPUT := $(while $(VAR) < 3,$(eval VAR:=$(expr $(VAR) + 1))$(VAR))
|
|---|
| 52 | ifneq ($(OUTPUT),1 2 3)
|
|---|
| 53 | $(error sub-test 0 failed:$(OUTPUT))
|
|---|
| 54 | endif
|
|---|
| 55 |
|
|---|
| 56 | ifneq (.$(while 0,asdfasdfadsf).,..)
|
|---|
| 57 | $(error sub-test 1 failed)
|
|---|
| 58 | endif
|
|---|
| 59 |
|
|---|
| 60 | .PHONY: all
|
|---|
| 61 | all: ; @:
|
|---|
| 62 | ',
|
|---|
| 63 | '',
|
|---|
| 64 | '');
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 | # Indicate that we're done.
|
|---|
| 70 | 1;
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|