Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests make(1): add tests for comparison to...



details:   https://anonhg.NetBSD.org/src/rev/cd676b0e2fe7
branches:  trunk
changeset: 976087:cd676b0e2fe7
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Sep 12 17:47:24 2020 +0000

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

diffstat:

 usr.bin/make/unit-tests/cond-token-plain.exp |  11 ++++++++++
 usr.bin/make/unit-tests/cond-token-plain.mk  |  29 +++++++++++++++++++++++++++-
 2 files changed, 39 insertions(+), 1 deletions(-)

diffs (61 lines):

diff -r 94bd44040aac -r cd676b0e2fe7 usr.bin/make/unit-tests/cond-token-plain.exp
--- a/usr.bin/make/unit-tests/cond-token-plain.exp      Sat Sep 12 17:14:40 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-token-plain.exp      Sat Sep 12 17:47:24 2020 +0000
@@ -15,4 +15,15 @@
 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
diff -r 94bd44040aac -r cd676b0e2fe7 usr.bin/make/unit-tests/cond-token-plain.mk
--- a/usr.bin/make/unit-tests/cond-token-plain.mk       Sat Sep 12 17:14:40 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-token-plain.mk       Sat Sep 12 17:47:24 2020 +0000
@@ -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:
        @:;



Home | Main Index | Thread Index | Old Index