freebsd-src/unit-tests/cond-token-number.mk
Simon J. Gerraty cdde9e894d Import bmake-20220204
Features of interest:

Allow setting target local variables (similar to gmake)

In META_MODE .MAKE.META.CMP_FILTER can be used for filtering commands
before comparion.

contrib/bmake/mk/cc-wrap.mk is an example of using these

See ChangeLog for the gory details.
2022-02-05 12:03:50 -08:00

92 lines
1.8 KiB
Makefile

# $NetBSD: cond-token-number.mk,v 1.7 2022/01/02 02:57:39 rillig Exp $
#
# Tests for number tokens in .if conditions.
#
# TODO: Add introduction.
.if 0
. error
.endif
# Even though -0 is a number and would be accepted by strtod, it is not
# accepted by the condition parser.
#
# See the ch_isdigit call in CondParser_String.
.if -0
. error
.else
. error
.endif
# Even though +0 is a number and would be accepted by strtod, it is not
# accepted by the condition parser.
#
# See the ch_isdigit call in CondParser_String.
.if +0
. error
.else
. error
.endif
# Even though -1 is a number and would be accepted by strtod, it is not
# accepted by the condition parser.
#
# See the ch_isdigit call in CondParser_String.
.if !-1
. error
.else
. error
.endif
# Even though +1 is a number and would be accepted by strtod, it is not
# accepted by the condition parser.
#
# See the ch_isdigit call in CondParser_String.
.if !+1
. error
.else
. error
.endif
# When the number comes from a variable expression though, it may be signed.
# XXX: This is inconsistent.
.if ${:U+0}
. error
.endif
# When the number comes from a variable expression though, it may be signed.
# XXX: This is inconsistent.
.if !${:U+1}
. error
.endif
# Hexadecimal numbers are accepted.
.if 0x0
. error
.endif
.if 0x1
.else
. error
.endif
# This is not a hexadecimal number, even though it has an x. It is
# interpreted as a string instead. In a plain '.if', such a token evaluates
# to true if it is non-empty. In other '.if' directives, such a token is
# evaluated by either FuncDefined or FuncMake.
.if 3x4
.else
. error
.endif
# Make can do radix conversion from hex.
HEX= dead
.if 0x${HEX} == 57005
.else
. error
.endif
# Ensure that parsing continues until here.
.info End of the tests.
all: # nothing