Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests make(1): add tests for string litera...



details:   https://anonhg.NetBSD.org/src/rev/a6dfc4662514
branches:  trunk
changeset: 958837:a6dfc4662514
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Jan 21 23:03:41 2021 +0000

description:
make(1): add tests for string literals in .ifdef

diffstat:

 usr.bin/make/unit-tests/directive-ifdef.exp |   2 ++
 usr.bin/make/unit-tests/directive-ifdef.mk  |  17 ++++++++++++++++-
 2 files changed, 18 insertions(+), 1 deletions(-)

diffs (38 lines):

diff -r 87d8d85526f1 -r a6dfc4662514 usr.bin/make/unit-tests/directive-ifdef.exp
--- a/usr.bin/make/unit-tests/directive-ifdef.exp       Thu Jan 21 22:54:13 2021 +0000
+++ b/usr.bin/make/unit-tests/directive-ifdef.exp       Thu Jan 21 23:03:41 2021 +0000
@@ -1,2 +1,4 @@
 make: "directive-ifdef.mk" line 12: Function calls in .ifdef are possible.
+make: "directive-ifdef.mk" line 23: String literals are tested for emptiness.
+make: "directive-ifdef.mk" line 27: String literals are tested for emptiness.  Whitespace is non-empty.
 exit status 0
diff -r 87d8d85526f1 -r a6dfc4662514 usr.bin/make/unit-tests/directive-ifdef.mk
--- a/usr.bin/make/unit-tests/directive-ifdef.mk        Thu Jan 21 22:54:13 2021 +0000
+++ b/usr.bin/make/unit-tests/directive-ifdef.mk        Thu Jan 21 23:03:41 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: directive-ifdef.mk,v 1.3 2020/11/08 22:38:28 rillig Exp $
+# $NetBSD: directive-ifdef.mk,v 1.4 2021/01/21 23:03:41 rillig Exp $
 #
 # Tests for the .ifdef directive.
 
@@ -14,5 +14,20 @@
 .  error
 .endif
 
+# String literals are handled the same in all variants of the .if directive.
+# They evaluate to true if they are not empty.  Whitespace counts as non-empty
+# as well.
+.ifdef ""
+.  error
+.else
+.  info String literals are tested for emptiness.
+.endif
+
+.ifdef " "
+.  info String literals are tested for emptiness.  Whitespace is non-empty.
+.else
+.  error
+.endif
+
 all:
        @:;



Home | Main Index | Thread Index | Old Index