Module Name:    src
Committed By:   rillig
Date:           Thu Aug 20 17:23:44 UTC 2020

Modified Files:
        src/usr.bin/make/unit-tests: cond-func-defined.exp cond-func-defined.mk

Log Message:
make(1): add test for the function defined(...)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/cond-func-defined.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cond-func-defined.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/cond-func-defined.exp
diff -u src/usr.bin/make/unit-tests/cond-func-defined.exp:1.1 src/usr.bin/make/unit-tests/cond-func-defined.exp:1.2
--- src/usr.bin/make/unit-tests/cond-func-defined.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/cond-func-defined.exp	Thu Aug 20 17:23:43 2020
@@ -1 +1,5 @@
-exit status 0
+make: "cond-func-defined.mk" line 25: warning: Missing closing parenthesis for defined()
+make: "cond-func-defined.mk" line 25: Malformed conditional (!defined(A B))
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1

Index: src/usr.bin/make/unit-tests/cond-func-defined.mk
diff -u src/usr.bin/make/unit-tests/cond-func-defined.mk:1.2 src/usr.bin/make/unit-tests/cond-func-defined.mk:1.3
--- src/usr.bin/make/unit-tests/cond-func-defined.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/cond-func-defined.mk	Thu Aug 20 17:23:43 2020
@@ -1,8 +1,33 @@
-# $NetBSD: cond-func-defined.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: cond-func-defined.mk,v 1.3 2020/08/20 17:23:43 rillig Exp $
 #
 # Tests for the defined() function in .if conditions.
 
-# TODO: Implementation
+DEF=		defined
+${:UA B}=	variable name with spaces
+
+.if !defined(DEF)
+.error
+.endif
+
+# Horizontal whitespace after the opening parenthesis is ignored.
+.if !defined( 	DEF)
+.error
+.endif
+
+# Horizontal whitespace before the closing parenthesis is ignored.
+.if !defined(DEF 	)
+.error
+.endif
+
+# The argument of a function must not directly contain whitespace.
+.if !defined(A B)
+.error
+.endif
+
+# If necessary, the whitespace can be generated by a variable expression.
+.if !defined(${:UA B})
+.error
+.endif
 
 all:
 	@:;

Reply via email to