Module Name: src Committed By: rillig Date: Sat Mar 4 08:07:29 UTC 2023
Modified Files: src/usr.bin/make/unit-tests: cond-cmp-numeric.exp cond-cmp-numeric.mk cond-token-number.exp cond-token-number.mk Log Message: tests/make: test very small and very large numbers in conditions To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/cond-cmp-numeric.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cond-cmp-numeric.mk cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cond-token-number.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cond-token-number.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/unit-tests/cond-cmp-numeric.exp diff -u src/usr.bin/make/unit-tests/cond-cmp-numeric.exp:1.8 src/usr.bin/make/unit-tests/cond-cmp-numeric.exp:1.9 --- src/usr.bin/make/unit-tests/cond-cmp-numeric.exp:1.8 Sun Sep 4 22:55:00 2022 +++ src/usr.bin/make/unit-tests/cond-cmp-numeric.exp Sat Mar 4 08:07:29 2023 @@ -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 Index: src/usr.bin/make/unit-tests/cond-cmp-numeric.mk diff -u src/usr.bin/make/unit-tests/cond-cmp-numeric.mk:1.6 src/usr.bin/make/unit-tests/cond-cmp-numeric.mk:1.7 --- src/usr.bin/make/unit-tests/cond-cmp-numeric.mk:1.6 Sun Sep 4 22:55:00 2022 +++ src/usr.bin/make/unit-tests/cond-cmp-numeric.mk Sat Mar 4 08:07:29 2023 @@ -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: - @:; Index: src/usr.bin/make/unit-tests/cond-token-number.exp diff -u src/usr.bin/make/unit-tests/cond-token-number.exp:1.5 src/usr.bin/make/unit-tests/cond-token-number.exp:1.6 --- src/usr.bin/make/unit-tests/cond-token-number.exp:1.5 Mon Dec 27 18:54:19 2021 +++ src/usr.bin/make/unit-tests/cond-token-number.exp Sat Mar 4 08:07:29 2023 @@ -2,7 +2,6 @@ make: "cond-token-number.mk" line 15: Ma 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 Index: src/usr.bin/make/unit-tests/cond-token-number.mk diff -u src/usr.bin/make/unit-tests/cond-token-number.mk:1.7 src/usr.bin/make/unit-tests/cond-token-number.mk:1.8 --- src/usr.bin/make/unit-tests/cond-token-number.mk:1.7 Sun Jan 2 02:57:39 2022 +++ src/usr.bin/make/unit-tests/cond-token-number.mk Sat Mar 4 08:07:29 2023 @@ -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: