1# $NetBSD: cond-token-number.mk,v 1.8 2023/03/04 08:07:29 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# Very small numbers round to 0.
89.if 12345e-400
90.  error
91.endif
92.if 12345e-200
93.else
94.  error
95.endif
96
97# Very large numbers round up to infinity on IEEE 754 implementations, or to
98# the largest representable number (VAX); in particular, make does not fall
99# back to checking whether a variable of that name is defined.
100.if 12345e400
101.else
102.  error
103.endif
104
105all:
106