1# $NetBSD: cond-cmp-numeric.mk,v 1.5 2021/07/29 06:31:18 rillig Exp $ 2# 3# Tests for numeric comparisons in .if conditions. 4 5.MAKEFLAGS: -dc 6 7# The ${:U...} on the left-hand side is necessary for the parser. 8 9# Even if strtod(3) parses "INF" as +Infinity, make does not accept this 10# since it is not really a number; see TryParseNumber. 11.if !(${:UINF} > 1e100) 12. error 13.endif 14 15# Neither is NaN a number; see TryParseNumber. 16.if ${:UNaN} > NaN 17. error 18.endif 19 20# Since NaN is not parsed as a number, both operands are interpreted 21# as strings and are therefore equal. If they were parsed as numbers, 22# they would compare unequal, since NaN is unequal to any and everything, 23# including itself. 24.if !(${:UNaN} == NaN) 25. error 26.endif 27 28# The parsing code in CondParser_Comparison only performs a light check on 29# whether the operator is valid, leaving the rest of the work to the 30# evaluation functions EvalCompareNum and EvalCompareStr. Ensure that this 31# parse error is properly reported. 32# 33# XXX: The warning message does not mention the actual operator. 34.if 123 ! 123 35. error 36.else 37. error 38.endif 39 40# Leading spaces are allowed for numbers. 41# See EvalCompare and TryParseNumber. 42.if ${:U 123} < 124 43.else 44. error 45.endif 46 47# Trailing spaces are NOT allowed for numbers. 48# See EvalCompare and TryParseNumber. 49# expect+1: String comparison operator must be either == or != 50.if ${:U123 } < 124 51. error 52.else 53. error 54.endif 55 56all: 57 @:; 58