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: document an edge case in...



details:   https://anonhg.NetBSD.org/src/rev/526f90eb32d2
branches:  trunk
changeset: 369924:526f90eb32d2
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Sep 08 05:43:20 2022 +0000

description:
tests/make: document an edge case in evaluating conditionals

diffstat:

 usr.bin/make/unit-tests/cond-cmp-unary.mk |  22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diffs (39 lines):

diff -r 4bf1a4ab471f -r 526f90eb32d2 usr.bin/make/unit-tests/cond-cmp-unary.mk
--- a/usr.bin/make/unit-tests/cond-cmp-unary.mk Thu Sep 08 05:26:34 2022 +0000
+++ b/usr.bin/make/unit-tests/cond-cmp-unary.mk Thu Sep 08 05:43:20 2022 +0000
@@ -1,11 +1,11 @@
-# $NetBSD: cond-cmp-unary.mk,v 1.2 2020/11/11 07:30:11 rillig Exp $
+# $NetBSD: cond-cmp-unary.mk,v 1.3 2022/09/08 05:43:20 rillig Exp $
 #
 # Tests for unary comparisons in .if conditions, that is, comparisons with
 # a single operand.  If the operand is a number, it is compared to zero,
 # if it is a string, it is tested for emptiness.
 
-# The number 0 evaluates to false.
-.if 0
+# The number 0 in all its various representations evaluates to false.
+.if 0 || 0.0 || 0e0 || 0.0e0 || 0.0e10
 .  error
 .endif
 
@@ -55,4 +55,20 @@
 .  error
 .endif
 
+# The condition '${VAR:M*}' is almost equivalent to '${VAR:M*} != ""'.  The
+# only case where they differ is for a single word whose numeric value is zero.
+.if ${:U0:M*}
+.  error
+.endif
+.if ${:U0:M*} == ""
+.  error
+.endif
+# Multiple words cannot be parsed as a single number, thus evaluating to true.
+.if !${:U0 0:M*}
+.  error
+.endif
+.if ${:U0 0:M*} == ""
+.  error
+.endif
+
 all: # nothing



Home | Main Index | Thread Index | Old Index