freebsd-nq/contrib/bmake/unit-tests/cond-cmp-string.mk
Simon J. Gerraty 2c3632d14f Update to bmake-20200902
Lots of code refactoring, simplification and cleanup.
Lots of new unit-tests providing much higher code coverage.
All courtesy of rillig at netbsd.

Other significant changes:

o new read-only variable .SHELL which provides the path of the shell
  used to run scripts (as defined by  the .SHELL target).

o variable parsing detects more errors.

o new debug option -dl: LINT mode, does the equivalent of := for all
  variable assignments so that file and line number are reported for
  variable parse errors.
2020-09-05 19:29:42 +00:00

40 lines
1.0 KiB
Makefile

# $NetBSD: cond-cmp-string.mk,v 1.3 2020/08/20 18:43:19 rillig Exp $
#
# Tests for string comparisons in .if conditions.
# This is a simple comparison of string literals.
# Nothing surprising here.
.if "str" != "str"
.error
.endif
# 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