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): demonstrate another unneces...



details:   https://anonhg.NetBSD.org/src/rev/67e25df23142
branches:  trunk
changeset: 935407:67e25df23142
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Jul 02 10:36:58 2020 +0000

description:
make(1): demonstrate another unnecessary condition evaluation

diffstat:

 usr.bin/make/unit-tests/cond-short.exp |   3 +++
 usr.bin/make/unit-tests/cond-short.mk  |  14 +++++++++++++-
 2 files changed, 16 insertions(+), 1 deletions(-)

diffs (41 lines):

diff -r 065408da2041 -r 67e25df23142 usr.bin/make/unit-tests/cond-short.exp
--- a/usr.bin/make/unit-tests/cond-short.exp    Thu Jul 02 10:28:11 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-short.exp    Thu Jul 02 10:36:58 2020 +0000
@@ -1,6 +1,9 @@
 expected and
 expected and exists
 expected and empty
+unexpected VAR U11
+expected U23 condition
+expected VAR23
 expected or
 expected or exists
 expected or empty
diff -r 065408da2041 -r 67e25df23142 usr.bin/make/unit-tests/cond-short.mk
--- a/usr.bin/make/unit-tests/cond-short.mk     Thu Jul 02 10:28:11 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-short.mk     Thu Jul 02 10:36:58 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: cond-short.mk,v 1.2 2020/06/28 11:06:26 rillig Exp $
+# $NetBSD: cond-short.mk,v 1.3 2020/07/02 10:36:58 rillig Exp $
 #
 # Demonstrates that in conditions, the right-hand side of an && or ||
 # is only evaluated if it can actually influence the result.
@@ -27,6 +27,18 @@
 .if 1 && empty(${echo "expected and empty" 1>&2 :L:sh})
 .endif
 
+# FIXME: "VAR U11" must not be evaluated.
+# The whole !empty condition must only be parsed and then discarded.
+VAR=   ${VAR${:U11${echo "unexpected VAR U11" 1>&2 :L:sh}}}
+VAR13= ${VAR${:U12${echo "unexpected VAR13" 1>&2 :L:sh}}}
+.if 0 && !empty(VAR${:U13${echo "unexpected U13 condition" 1>&2 :L:sh}})
+.endif
+
+VAR=   ${VAR${:U21${echo "unexpected VAR U21" 1>&2 :L:sh}}}
+VAR23= ${VAR${:U22${echo   "expected VAR23" 1>&2 :L:sh}}}
+.if 1 && !empty(VAR${:U23${echo   "expected U23 condition" 1>&2 :L:sh}})
+.endif
+
 # The || operator.
 
 .if 1 || ${echo "unexpected or" 1>&2 :L:sh}



Home | Main Index | Thread Index | Old Index