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 tests/make: add tests for irrelevant...
details: https://anonhg.NetBSD.org/src/rev/a49c01be824d
branches: trunk
changeset: 1027574:a49c01be824d
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Dec 12 09:49:09 2021 +0000
description:
tests/make: add tests for irrelevant function calls
diffstat:
usr.bin/make/unit-tests/cond-short.mk | 54 ++++++++++++++++++++++++++++++++++-
1 files changed, 53 insertions(+), 1 deletions(-)
diffs (66 lines):
diff -r cad60719a01a -r a49c01be824d usr.bin/make/unit-tests/cond-short.mk
--- a/usr.bin/make/unit-tests/cond-short.mk Sun Dec 12 09:36:00 2021 +0000
+++ b/usr.bin/make/unit-tests/cond-short.mk Sun Dec 12 09:49:09 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: cond-short.mk,v 1.17 2021/09/07 20:41:58 rillig Exp $
+# $NetBSD: cond-short.mk,v 1.18 2021/12/12 09:49:09 rillig Exp $
#
# Demonstrates that in conditions, the right-hand side of an && or ||
# is only evaluated if it can actually influence the result.
@@ -224,4 +224,56 @@
. error
.endif
+
+# Ensure that irrelevant conditions do not influence the result of the whole
+# condition. As of cond.c 1.302 from 2021-12-11, an irrelevant function call
+# evaluates to true (see CondParser_FuncCall and CondParser_FuncCallEmpty), an
+# irrelevant comparison evaluates to false (see CondParser_Comparison).
+#
+# An irrelevant true bubbles up to the outermost CondParser_And, where it is
+# ignored. An irrelevant false bubbles up to the outermost CondParser_Or,
+# where it is ignored.
+#
+# If the condition parser should ever be restructured, the bubbling up of the
+# irrelevant evaluation results might show up accidentally. Prevent this.
+DEF= defined
+.undef UNDEF
+
+.if 0 && defined(DEF)
+. error
+.endif
+
+.if 1 && defined(DEF)
+.else
+. error
+.endif
+
+.if 0 && defined(UNDEF)
+. error
+.endif
+
+.if 1 && defined(UNDEF)
+. error
+.endif
+
+.if 0 || defined(DEF)
+.else
+. error
+.endif
+
+.if 1 || defined(DEF)
+.else
+. error
+.endif
+
+.if 0 || defined(UNDEF)
+. error
+.endif
+
+.if 1 || defined(UNDEF)
+.else
+. error
+.endif
+
+
all:
Home |
Main Index |
Thread Index |
Old Index