Module Name: src Committed By: rillig Date: Sat Sep 12 18:01:51 UTC 2020
Modified Files: src/usr.bin/make/unit-tests: cond-cmp-numeric.exp cond-cmp-numeric.mk Log Message: make(1): add test for Infinity and NaN Neither is recognized by the make parser, which is good since the main task of make is dependency resolution and text processing, not calculating. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/cond-cmp-numeric.exp cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cond-cmp-numeric.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.1 src/usr.bin/make/unit-tests/cond-cmp-numeric.exp:1.2 --- src/usr.bin/make/unit-tests/cond-cmp-numeric.exp:1.1 Sun Aug 16 12:07:51 2020 +++ src/usr.bin/make/unit-tests/cond-cmp-numeric.exp Sat Sep 12 18:01:51 2020 @@ -1 +1,11 @@ -exit status 0 +CondParser_Eval: !(${:UINF} > 1e100) +make: "cond-cmp-numeric.mk" line 11: warning: String comparison operator must be either == or != +make: "cond-cmp-numeric.mk" line 11: Malformed conditional (!(${:UINF} > 1e100)) +CondParser_Eval: ${:UNaN} > NaN +make: "cond-cmp-numeric.mk" line 16: warning: String comparison operator must be either == or != +make: "cond-cmp-numeric.mk" line 16: Malformed conditional (${:UNaN} > NaN) +CondParser_Eval: !(${:UNaN} == NaN) +lhs = "NaN", rhs = "NaN", op = == +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.2 src/usr.bin/make/unit-tests/cond-cmp-numeric.mk:1.3 --- src/usr.bin/make/unit-tests/cond-cmp-numeric.mk:1.2 Sun Aug 16 14:25:16 2020 +++ src/usr.bin/make/unit-tests/cond-cmp-numeric.mk Sat Sep 12 18:01:51 2020 @@ -1,8 +1,29 @@ -# $NetBSD: cond-cmp-numeric.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $ +# $NetBSD: cond-cmp-numeric.mk,v 1.3 2020/09/12 18:01:51 rillig Exp $ # # Tests for numeric comparisons in .if conditions. -# TODO: Implementation +.MAKEFLAGS: -dc + +# The ${:U...} on the left-hand side is necessary for the parser. + +# Even if strtod(3) parses "INF" as +Infinity, make does not accept this +# since it is not really a number; see TryParseNumber. +.if !(${:UINF} > 1e100) +. error +.endif + +# Neither is NaN a number; see TryParseNumber. +.if ${:UNaN} > NaN +. error +.endif + +# Since NaN is not parsed as a number, both operands are interpreted +# as strings and are therefore equal. If they were parsed as numbers, +# they would compare unequal, since NaN is unequal to any and everything, +# including itself. +.if !(${:UNaN} == NaN) +. error +.endif all: @:;