summaryrefslogtreecommitdiff
path: root/usr.bin/make
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2023-03-04 08:07:29 +0000
committerrillig <rillig@NetBSD.org>2023-03-04 08:07:29 +0000
commit5203d9e0059538ba1cf24abbdaeb5deb360c1997 (patch)
tree92dc42a9c035300b357be9e273919bdfbbdf37bf /usr.bin/make
parentf980e1f7aaa56800dac19fbdbba0fe82edb52a02 (diff)
tests/make: test very small and very large numbers in conditions
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/unit-tests/cond-cmp-numeric.exp8
-rw-r--r--usr.bin/make/unit-tests/cond-cmp-numeric.mk11
-rw-r--r--usr.bin/make/unit-tests/cond-token-number.exp1
-rw-r--r--usr.bin/make/unit-tests/cond-token-number.mk22
4 files changed, 29 insertions, 13 deletions
diff --git a/usr.bin/make/unit-tests/cond-cmp-numeric.exp b/usr.bin/make/unit-tests/cond-cmp-numeric.exp
index c03ecd1b311..69a8a1e4fca 100644
--- a/usr.bin/make/unit-tests/cond-cmp-numeric.exp
+++ b/usr.bin/make/unit-tests/cond-cmp-numeric.exp
@@ -1,15 +1,15 @@
CondParser_Eval: !(${:UINF} > 1e100)
-make: "cond-cmp-numeric.mk" line 11: Comparison with '>' requires both operands 'INF' and '1e100' to be numeric
+make: "cond-cmp-numeric.mk" line 15: Comparison with '>' requires both operands 'INF' and '1e100' to be numeric
CondParser_Eval: ${:UNaN} > NaN
-make: "cond-cmp-numeric.mk" line 16: Comparison with '>' requires both operands 'NaN' and 'NaN' to be numeric
+make: "cond-cmp-numeric.mk" line 21: Comparison with '>' requires both operands 'NaN' and 'NaN' to be numeric
CondParser_Eval: !(${:UNaN} == NaN)
Comparing "NaN" == "NaN"
CondParser_Eval: 123 ! 123
-make: "cond-cmp-numeric.mk" line 34: Malformed conditional (123 ! 123)
+make: "cond-cmp-numeric.mk" line 38: Malformed conditional (123 ! 123)
CondParser_Eval: ${:U 123} < 124
Comparing 123.000000 < 124.000000
CondParser_Eval: ${:U123 } < 124
-make: "cond-cmp-numeric.mk" line 50: Comparison with '<' requires both operands '123 ' and '124' to be numeric
+make: "cond-cmp-numeric.mk" line 54: Comparison with '<' requires both operands '123 ' and '124' to be numeric
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
diff --git a/usr.bin/make/unit-tests/cond-cmp-numeric.mk b/usr.bin/make/unit-tests/cond-cmp-numeric.mk
index 5386e4a9729..e025b99b27c 100644
--- a/usr.bin/make/unit-tests/cond-cmp-numeric.mk
+++ b/usr.bin/make/unit-tests/cond-cmp-numeric.mk
@@ -1,6 +1,9 @@
-# $NetBSD: cond-cmp-numeric.mk,v 1.6 2022/09/04 22:55:00 rillig Exp $
+# $NetBSD: cond-cmp-numeric.mk,v 1.7 2023/03/04 08:07:29 rillig Exp $
#
# Tests for numeric comparisons in .if conditions.
+#
+# See also:
+# cond-token-number.mk
.MAKEFLAGS: -dc
@@ -8,11 +11,13 @@
# Even if strtod(3) parses "INF" as +Infinity, make does not accept this
# since it is not really a number; see TryParseNumber.
+# expect+1: Comparison with '>' requires both operands 'INF' and '1e100' to be numeric
.if !(${:UINF} > 1e100)
. error
.endif
# Neither is NaN a number; see TryParseNumber.
+# expect+1: Comparison with '>' requires both operands 'NaN' and 'NaN' to be numeric
.if ${:UNaN} > NaN
. error
.endif
@@ -29,8 +34,7 @@
# whether the operator is valid, leaving the rest of the work to the
# evaluation functions EvalCompareNum and EvalCompareStr. Ensure that this
# parse error is properly reported.
-#
-# XXX: The warning message does not mention the actual operator.
+# expect+1: Malformed conditional (123 ! 123)
.if 123 ! 123
. error
.else
@@ -54,4 +58,3 @@
.endif
all:
- @:;
diff --git a/usr.bin/make/unit-tests/cond-token-number.exp b/usr.bin/make/unit-tests/cond-token-number.exp
index f078cb00732..1d472b63bc7 100644
--- a/usr.bin/make/unit-tests/cond-token-number.exp
+++ b/usr.bin/make/unit-tests/cond-token-number.exp
@@ -2,7 +2,6 @@ make: "cond-token-number.mk" line 15: Malformed conditional (-0)
make: "cond-token-number.mk" line 25: Malformed conditional (+0)
make: "cond-token-number.mk" line 35: Malformed conditional (!-1)
make: "cond-token-number.mk" line 45: Malformed conditional (!+1)
-make: "cond-token-number.mk" line 89: End of the tests.
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
diff --git a/usr.bin/make/unit-tests/cond-token-number.mk b/usr.bin/make/unit-tests/cond-token-number.mk
index eef528f4b7c..d1dd7371f44 100644
--- a/usr.bin/make/unit-tests/cond-token-number.mk
+++ b/usr.bin/make/unit-tests/cond-token-number.mk
@@ -1,4 +1,4 @@
-# $NetBSD: cond-token-number.mk,v 1.7 2022/01/02 02:57:39 rillig Exp $
+# $NetBSD: cond-token-number.mk,v 1.8 2023/03/04 08:07:29 rillig Exp $
#
# Tests for number tokens in .if conditions.
#
@@ -85,7 +85,21 @@ HEX= dead
. error
.endif
-# Ensure that parsing continues until here.
-.info End of the tests.
+# Very small numbers round to 0.
+.if 12345e-400
+. error
+.endif
+.if 12345e-200
+.else
+. error
+.endif
+
+# Very large numbers round up to infinity on IEEE 754 implementations, or to
+# the largest representable number (VAX); in particular, make does not fall
+# back to checking whether a variable of that name is defined.
+.if 12345e400
+.else
+. error
+.endif
-all: # nothing
+all: