Module Name:    src
Committed By:   rillig
Date:           Thu Jan 21 23:03:41 UTC 2021

Modified Files:
        src/usr.bin/make/unit-tests: directive-ifdef.exp directive-ifdef.mk

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


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/directive-ifdef.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/directive-ifdef.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/directive-ifdef.exp
diff -u src/usr.bin/make/unit-tests/directive-ifdef.exp:1.2 src/usr.bin/make/unit-tests/directive-ifdef.exp:1.3
--- src/usr.bin/make/unit-tests/directive-ifdef.exp:1.2	Sun Nov  8 22:38:28 2020
+++ src/usr.bin/make/unit-tests/directive-ifdef.exp	Thu Jan 21 23:03:41 2021
@@ -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

Index: src/usr.bin/make/unit-tests/directive-ifdef.mk
diff -u src/usr.bin/make/unit-tests/directive-ifdef.mk:1.3 src/usr.bin/make/unit-tests/directive-ifdef.mk:1.4
--- src/usr.bin/make/unit-tests/directive-ifdef.mk:1.3	Sun Nov  8 22:38:28 2020
+++ src/usr.bin/make/unit-tests/directive-ifdef.mk	Thu Jan 21 23:03:41 2021
@@ -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 @@ DEFINED=	defined
 .  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:
 	@:;

Reply via email to