Module Name: src Committed By: rillig Date: Tue Nov 10 19:36:50 UTC 2020
Modified Files: src/usr.bin/make/unit-tests: cond-func.exp cond-func.mk Log Message: make(1): add tests for edge cases in parsing conditionals To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cond-func.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cond-func.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.exp diff -u src/usr.bin/make/unit-tests/cond-func.exp:1.2 src/usr.bin/make/unit-tests/cond-func.exp:1.3 --- src/usr.bin/make/unit-tests/cond-func.exp:1.2 Sun Nov 8 21:40:13 2020 +++ src/usr.bin/make/unit-tests/cond-func.exp Tue Nov 10 19:36:50 2020 @@ -4,6 +4,11 @@ make: "cond-func.mk" line 49: warning: M make: "cond-func.mk" line 49: Malformed conditional (!defined(A&B)) make: "cond-func.mk" line 52: warning: Missing closing parenthesis for defined() make: "cond-func.mk" line 52: Malformed conditional (!defined(A|B)) +make: "cond-func.mk" line 92: The empty variable is never defined. +make: "cond-func.mk" line 100: A plain function name is parsed as !empty(...). +make: "cond-func.mk" line 107: A plain function name is parsed as !empty(...). +make: "cond-func.mk" line 117: Symbols may start with a function name. +make: "cond-func.mk" line 122: Symbols may start with a function name. make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/cond-func.mk diff -u src/usr.bin/make/unit-tests/cond-func.mk:1.6 src/usr.bin/make/unit-tests/cond-func.mk:1.7 --- src/usr.bin/make/unit-tests/cond-func.mk:1.6 Sun Nov 8 21:40:13 2020 +++ src/usr.bin/make/unit-tests/cond-func.mk Tue Nov 10 19:36:50 2020 @@ -1,4 +1,4 @@ -# $NetBSD: cond-func.mk,v 1.6 2020/11/08 21:40:13 rillig Exp $ +# $NetBSD: cond-func.mk,v 1.7 2020/11/10 19:36:50 rillig Exp $ # # Tests for those parts of the functions in .if conditions that are common # among several functions. @@ -86,5 +86,43 @@ ${VARNAME_UNBALANCED_BRACES}= variable n . error .endif +.if defined() +. error +.else +. info The empty variable is never defined. +.endif + +# The plain word 'defined' is interpreted as '!empty(defined)'. +# That variable is not defined (yet). +.if defined +. error +.else +. info A plain function name is parsed as !empty(...). +.endif + +# If a variable named 'defined' is actually defined and not empty, the plain +# symbol 'defined' evaluates to true. +defined= non-empty +.if defined +. info A plain function name is parsed as !empty(...). +.else +. error +.endif + +# A plain symbol name may start with one of the function names, in this case +# 'defined'. +.if defined-var +. error +.else +. info Symbols may start with a function name. +.endif + +defined-var= non-empty +.if defined-var +. info Symbols may start with a function name. +.else +. error +.endif + all: @:;