make(1): add tests for comparison tokens without whitespace

This commit is contained in:
rillig 2020-09-12 17:47:24 +00:00
parent 1dfbf55e58
commit 3c08467d34
2 changed files with 39 additions and 1 deletions

View File

@ -15,4 +15,15 @@ lhs = "no", rhs = "no", op = !=
CondParser_Eval: ${1 # comment :?yes:no} != yes
CondParser_Eval: 1 # comment
lhs = "yes", rhs = "yes", op = !=
CondParser_Eval: ${UNDEF:Uundefined}!=undefined
lhs = "undefined", rhs = "undefined", op = !=
CondParser_Eval: ${UNDEF:U12345}>12345
lhs = 12345.000000, rhs = 12345.000000, op = >1
CondParser_Eval: ${UNDEF:U12345}<12345
lhs = 12345.000000, rhs = 12345.000000, op = <1
CondParser_Eval: (${UNDEF:U0})||0
CondParser_Eval: ${:Uvar}&&name != "var&&name"
lhs = "var&&name", rhs = "var&&name", op = !=
CondParser_Eval: ${:Uvar}||name != "var||name"
lhs = "var||name", rhs = "var||name", op = !=
exit status 0

View File

@ -1,4 +1,4 @@
# $NetBSD: cond-token-plain.mk,v 1.3 2020/09/11 06:47:42 rillig Exp $
# $NetBSD: cond-token-plain.mk,v 1.4 2020/09/12 17:47:24 rillig Exp $
#
# Tests for plain tokens (that is, string literals without quotes)
# in .if conditions.
@ -63,5 +63,32 @@
. error
.endif
# Usually there is whitespace around the comparison operator, but this is
# not required.
.if ${UNDEF:Uundefined}!=undefined
. error
.endif
.if ${UNDEF:U12345}>12345
. error
.endif
.if ${UNDEF:U12345}<12345
. error
.endif
.if (${UNDEF:U0})||0
. error
.endif
# Only the comparison operator terminates the comparison operand, and it's
# a coincidence that the '!' is both used in the '!=' comparison operator
# as well as for negating a comparison result.
#
# The boolean operators '&' and '|' don't terminate a comparison operand.
.if ${:Uvar}&&name != "var&&name"
. error
.endif
.if ${:Uvar}||name != "var||name"
. error
.endif
all:
@:;