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: demonstrate handling of ...



details:   https://anonhg.NetBSD.org/src/rev/a99457250e57
branches:  trunk
changeset: 1021628:a99457250e57
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Jun 11 13:01:28 2021 +0000

description:
tests/make: demonstrate handling of '+' and '*' in modifier ':?'

It doesn't make sense that these two characters are handled differently,
but that's what the current code has been doing for years.

diffstat:

 usr.bin/make/unit-tests/varmod-ifelse.exp |   4 ++++
 usr.bin/make/unit-tests/varmod-ifelse.mk  |  13 ++++++++++++-
 2 files changed, 16 insertions(+), 1 deletions(-)

diffs (38 lines):

diff -r 5303853f940d -r a99457250e57 usr.bin/make/unit-tests/varmod-ifelse.exp
--- a/usr.bin/make/unit-tests/varmod-ifelse.exp Fri Jun 11 12:54:22 2021 +0000
+++ b/usr.bin/make/unit-tests/varmod-ifelse.exp Fri Jun 11 13:01:28 2021 +0000
@@ -23,6 +23,10 @@
 make: "varmod-ifelse.mk" line 159: .
 make: Bad conditional expression 'string == "literal" ||  >= 10' in 'string == "literal" ||  >= 10?yes:no'
 make: "varmod-ifelse.mk" line 160: .
+make: "varmod-ifelse.mk" line 167: true
+make: "varmod-ifelse.mk" line 169: false
+make: Bad conditional expression '     ' in '  ?true:false'
+make: "varmod-ifelse.mk" line 171: 
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
diff -r 5303853f940d -r a99457250e57 usr.bin/make/unit-tests/varmod-ifelse.mk
--- a/usr.bin/make/unit-tests/varmod-ifelse.mk  Fri Jun 11 12:54:22 2021 +0000
+++ b/usr.bin/make/unit-tests/varmod-ifelse.mk  Fri Jun 11 13:01:28 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-ifelse.mk,v 1.16 2021/04/19 23:51:42 rillig Exp $
+# $NetBSD: varmod-ifelse.mk,v 1.17 2021/06/11 13:01:28 rillig Exp $
 #
 # Tests for the ${cond:?then:else} variable modifier, which evaluates either
 # the then-expression or the else-expression, depending on the condition.
@@ -158,3 +158,14 @@
 NUMBER=                # empty, not really a number either
 .info ${${STRING} == "literal" && ${NUMBER} >= 10:?yes:no}.
 .info ${${STRING} == "literal" || ${NUMBER} >= 10:?yes:no}.
+
+# CondParser_LeafToken handles [0-9-+] specially, treating them as a number.
+PLUS=          +
+ASTERISK=      *
+EMPTY=         # empty
+# "true" since "+" is not the empty string.
+.info ${${PLUS}                :?true:false}
+# "false" since the variable named "*" is not defined.
+.info ${${ASTERISK}    :?true:false}
+# syntax error since the condition is completely blank.
+.info ${${EMPTY}       :?true:false}



Home | Main Index | Thread Index | Old Index