make(1): add test for string literals in comparisons
This commit is contained in:
parent
e2b47da546
commit
2c405fed67
@ -1 +1,5 @@
|
||||
exit status 0
|
||||
make: "cond-cmp-string.mk" line 18: Malformed conditional (str != str)
|
||||
make: "cond-cmp-string.mk" line 37: Malformed conditional ("string" != "str""ing")
|
||||
make: Fatal errors encountered -- cannot continue
|
||||
make: stopped in unit-tests
|
||||
exit status 1
|
||||
|
@ -1,8 +1,39 @@
|
||||
# $NetBSD: cond-cmp-string.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
|
||||
# $NetBSD: cond-cmp-string.mk,v 1.3 2020/08/20 18:43:19 rillig Exp $
|
||||
#
|
||||
# Tests for string comparisons in .if conditions.
|
||||
|
||||
# TODO: Implementation
|
||||
# This is a simple comparison of string literals.
|
||||
# Nothing surprising here.
|
||||
.if "str" != "str"
|
||||
.error
|
||||
.endif
|
||||
|
||||
all:
|
||||
@:;
|
||||
# The right-hand side of the comparison may be written without quotes.
|
||||
.if "str" != str
|
||||
.error
|
||||
.endif
|
||||
|
||||
# The left-hand side of the comparison must be enclosed in quotes.
|
||||
# This one is not enclosed in quotes and thus generates an error message.
|
||||
.if str != str
|
||||
.error
|
||||
.endif
|
||||
|
||||
# The left-hand side of the comparison requires a defined variable.
|
||||
# The variable named "" is not defined, but applying the :U modifier to it
|
||||
# makes it "kind of defined" (see VAR_KEEP). Therefore it is ok here.
|
||||
.if ${:Ustr} != "str"
|
||||
.error
|
||||
.endif
|
||||
|
||||
# Any character in a string literal may be escaped using a backslash.
|
||||
# This means that "\n" does not mean a newline but a simple "n".
|
||||
.if "string" != "\s\t\r\i\n\g"
|
||||
.error
|
||||
.endif
|
||||
|
||||
# It is not possible to concatenate two string literals to form a single
|
||||
# string.
|
||||
.if "string" != "str""ing"
|
||||
.error
|
||||
.endif
|
||||
|
Loading…
Reference in New Issue
Block a user