diff options
Diffstat (limited to 'unit-tests/directive-ifdef.mk')
-rw-r--r-- | unit-tests/directive-ifdef.mk | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/unit-tests/directive-ifdef.mk b/unit-tests/directive-ifdef.mk index 12f3648e8b2c..8a60fb4a2669 100644 --- a/unit-tests/directive-ifdef.mk +++ b/unit-tests/directive-ifdef.mk @@ -1,33 +1,51 @@ -# $NetBSD: directive-ifdef.mk,v 1.4 2021/01/21 23:03:41 rillig Exp $ +# $NetBSD: directive-ifdef.mk,v 1.5 2022/01/23 21:48:59 rillig Exp $ # -# Tests for the .ifdef directive. - -# TODO: Implementation +# Tests for the .ifdef directive, which evaluates bare words by calling +# 'defined(word)'. DEFINED= defined +# There is no variable named 'UNDEF', therefore the condition evaluates to +# false. +.ifdef UNDEF +. error +.endif + +# There is a variable named 'DEFINED', so the condition evaluates to true. +.ifdef DEFINED +.else +. error +.endif + +# Since a bare word is an abbreviation for 'defined(word)', these can be +# used to construct complex conditions. +.ifdef UNDEF && DEFINED +. error +.endif +.ifdef UNDEF || DEFINED +.else +. error +.endif + # It looks redundant to have a call to defined() in an .ifdef, but it's -# possible. The .ifdef only affects plain symbols, not function calls. +# possible. The '.ifdef' only affects bare words, not function calls. .ifdef defined(DEFINED) -. info Function calls in .ifdef are possible. .else . 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. +# String literals are handled the same in all variants of the '.if' directive, +# they evaluate to true if they are not empty, therefore this particular +# example looks confusing and is thus not found in practice. .ifdef "" . error .else -. info String literals are tested for emptiness. .endif +# Whitespace counts as non-empty as well. .ifdef " " -. info String literals are tested for emptiness. Whitespace is non-empty. .else . error .endif -all: - @:; +all: .PHONY |