aboutsummaryrefslogtreecommitdiff
path: root/contrib/bmake/unit-tests/cond-token-number.mk
blob: 93e2646a60eb0911158c36c9b6cea5b67bd824a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# $NetBSD: cond-token-number.mk,v 1.5 2020/11/15 14:58:14 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, effectively meaning defined(3x4).
.if 3x4
.else
.  error
.endif

# Ensure that parsing continues until here.
.info End of the tests.

all: # nothing