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): add test for comparison of ...



details:   https://anonhg.NetBSD.org/src/rev/fcd3e9aa2c71
branches:  trunk
changeset: 942491:fcd3e9aa2c71
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Nov 08 21:47:59 2020 +0000

description:
make(1): add test for comparison of large integers

diffstat:

 usr.bin/make/unit-tests/cond-cmp-numeric-eq.exp |   6 +++---
 usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk  |  15 ++++++++++++++-
 2 files changed, 17 insertions(+), 4 deletions(-)

diffs (42 lines):

diff -r 3660f96319ff -r fcd3e9aa2c71 usr.bin/make/unit-tests/cond-cmp-numeric-eq.exp
--- a/usr.bin/make/unit-tests/cond-cmp-numeric-eq.exp   Sun Nov 08 21:40:13 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-cmp-numeric-eq.exp   Sun Nov 08 21:47:59 2020 +0000
@@ -1,6 +1,6 @@
-make: "cond-cmp-numeric-eq.mk" line 54: warning: Unknown operator
-make: "cond-cmp-numeric-eq.mk" line 54: Malformed conditional (!(12345 = 12345))
-make: "cond-cmp-numeric-eq.mk" line 61: Malformed conditional (!(12345 === 12345))
+make: "cond-cmp-numeric-eq.mk" line 67: warning: Unknown operator
+make: "cond-cmp-numeric-eq.mk" line 67: Malformed conditional (!(12345 = 12345))
+make: "cond-cmp-numeric-eq.mk" line 74: Malformed conditional (!(12345 === 12345))
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
diff -r 3660f96319ff -r fcd3e9aa2c71 usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk
--- a/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk    Sun Nov 08 21:40:13 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk    Sun Nov 08 21:47:59 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: cond-cmp-numeric-eq.mk,v 1.4 2020/10/24 08:46:08 rillig Exp $
+# $NetBSD: cond-cmp-numeric-eq.mk,v 1.5 2020/11/08 21:47:59 rillig Exp $
 #
 # Tests for numeric comparisons with the == operator in .if conditions.
 
@@ -49,6 +49,19 @@
 .  error
 .endif
 
+# Because an IEEE 754 double can only hold integers with a mantissa of 53
+# bits, these two numbers are considered the same.  The 993 is rounded down
+# to the 992.
+.if 9007199254740993 == 9007199254740992
+.else
+. error
+.endif
+# The 995 is rounded up, the 997 is rounded down.
+.if 9007199254740995 == 9007199254740997
+.else
+. error Probably a misconfiguration in the floating point environment, \
+       or maybe a machine without IEEE 754 floating point support.
+.endif
 
 # There is no = operator for numbers.
 .if !(12345 = 12345)



Home | Main Index | Thread Index | Old Index