1# $NetBSD: cond-token-number.mk,v 1.7 2022/01/02 02:57:39 rillig Exp $
2#
3# Tests for number tokens in .if conditions.
4#
5# TODO: Add introduction.
6
7.if 0
8.  error
9.endif
10
11# Even though -0 is a number and would be accepted by strtod, it is not
12# accepted by the condition parser.
13#
14# See the ch_isdigit call in CondParser_String.
15.if -0
16.  error
17.else
18.  error
19.endif
20
21# Even though +0 is a number and would be accepted by strtod, it is not
22# accepted by the condition parser.
23#
24# See the ch_isdigit call in CondParser_String.
25.if +0
26.  error
27.else
28.  error
29.endif
30
31# Even though -1 is a number and would be accepted by strtod, it is not
32# accepted by the condition parser.
33#
34# See the ch_isdigit call in CondParser_String.
35.if !-1
36.  error
37.else
38.  error
39.endif
40
41# Even though +1 is a number and would be accepted by strtod, it is not
42# accepted by the condition parser.
43#
44# See the ch_isdigit call in CondParser_String.
45.if !+1
46.  error
47.else
48.  error
49.endif
50
51# When the number comes from a variable expression though, it may be signed.
52# XXX: This is inconsistent.
53.if ${:U+0}
54.  error
55.endif
56
57# When the number comes from a variable expression though, it may be signed.
58# XXX: This is inconsistent.
59.if !${:U+1}
60.  error
61.endif
62
63# Hexadecimal numbers are accepted.
64.if 0x0
65.  error
66.endif
67.if 0x1
68.else
69.  error
70.endif
71
72# This is not a hexadecimal number, even though it has an x.  It is
73# interpreted as a string instead.  In a plain '.if', such a token evaluates
74# to true if it is non-empty.  In other '.if' directives, such a token is
75# evaluated by either FuncDefined or FuncMake.
76.if 3x4
77.else
78.  error
79.endif
80
81# Make can do radix conversion from hex.
82HEX=	dead
83.if 0x${HEX} == 57005
84.else
85.  error
86.endif
87
88# Ensure that parsing continues until here.
89.info End of the tests.
90
91all: # nothing
92