2c3632d14f
Lots of code refactoring, simplification and cleanup. Lots of new unit-tests providing much higher code coverage. All courtesy of rillig at netbsd. Other significant changes: o new read-only variable .SHELL which provides the path of the shell used to run scripts (as defined by the .SHELL target). o variable parsing detects more errors. o new debug option -dl: LINT mode, does the equivalent of := for all variable assignments so that file and line number are reported for variable parse errors.
54 lines
1002 B
Makefile
Executable File
54 lines
1002 B
Makefile
Executable File
# $NetBSD: cond-cmp-numeric-eq.mk,v 1.1 2020/08/23 13:50:17 rillig Exp $
|
|
#
|
|
# Tests for numeric comparisons with the == operator in .if conditions.
|
|
|
|
# This comparison yields the same result, whether numeric or character-based.
|
|
.if 1 == 1
|
|
.else
|
|
.error
|
|
.endif
|
|
|
|
# This comparison yields the same result, whether numeric or character-based.
|
|
.if 1 == 2
|
|
.error
|
|
.endif
|
|
|
|
.if 2 == 1
|
|
.error
|
|
.endif
|
|
|
|
# Scientific notation is supported, as per strtod.
|
|
.if 2e7 == 2000e4
|
|
.else
|
|
.error
|
|
.endif
|
|
|
|
.if 2000e4 == 2e7
|
|
.else
|
|
.error
|
|
.endif
|
|
|
|
# Trailing zeroes after the decimal point are irrelevant for the numeric
|
|
# value.
|
|
.if 3.30000 == 3.3
|
|
.else
|
|
.error
|
|
.endif
|
|
|
|
.if 3.3 == 3.30000
|
|
.else
|
|
.error
|
|
.endif
|
|
|
|
# As of 2020-08-23, numeric comparison is implemented as parsing both sides
|
|
# as double, and then performing a normal comparison. The range of double is
|
|
# typically 16 or 17 significant digits, therefore these two numbers seem to
|
|
# be equal.
|
|
.if 1.000000000000000001 == 1.000000000000000002
|
|
.else
|
|
.error
|
|
.endif
|
|
|
|
all:
|
|
@:;
|