xref: /freebsd/contrib/bmake/unit-tests/cond-cmp-numeric-ne.mk (revision c8e7f78a3d28ff6e6223ed136ada8e1e2f34965e)
1# $NetBSD: cond-cmp-numeric-ne.mk,v 1.3 2023/09/07 05:36:33 rillig Exp $
2#
3# Tests for numeric comparisons with the != operator in .if conditions.
4
5# When both sides are equal, the != operator always yields false.
6.if 1 != 1
7.  error
8.endif
9
10# This comparison yields the same result, whether numeric or character-based.
11.if 1 != 2
12.else
13.  error
14.endif
15
16.if 2 != 1
17.else
18.  error
19.endif
20
21# Scientific notation is supported, as per strtod.
22.if 2e7 != 2000e4
23.  error
24.endif
25
26.if 2000e4 != 2e7
27.  error
28.endif
29
30# Trailing zeroes after the decimal point are irrelevant for the numeric
31# value.
32.if 3.30000 != 3.3
33.  error
34.endif
35
36.if 3.3 != 3.30000
37.  error
38.endif
39
40# Numeric comparison works by parsing both sides
41# as double, and then performing a normal comparison.  The range of double is
42# typically 16 or 17 significant digits, therefore these two numbers seem to
43# be equal.
44.if 1.000000000000000001 != 1.000000000000000002
45.  error
46.endif
47
48all:
49	@:;
50