]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/bmake/unit-tests/cond-cmp-unary.mk
Update to bmake-20201101
[FreeBSD/FreeBSD.git] / contrib / bmake / unit-tests / cond-cmp-unary.mk
1 # $NetBSD: cond-cmp-unary.mk,v 1.1 2020/09/14 06:22:59 rillig Exp $
2 #
3 # Tests for unary comparisons in .if conditions, that is, comparisons with
4 # a single operand.  If the operand is a number, it is compared to zero,
5 # if it is a string, it is tested for emptiness.
6
7 # The number 0 evaluates to false.
8 .if 0
9 .  error
10 .endif
11
12 # Any other number evaluates to true.
13 .if !12345
14 .  error
15 .endif
16
17 # The empty string evaluates to false.
18 .if ""
19 .  error
20 .endif
21
22 # Any other string evaluates to true.
23 .if !"0"
24 .  error
25 .endif
26
27 # The empty string may come from a variable expression.
28 .if ${:U}
29 .  error
30 .endif
31
32 # A variable expression that is not surrounded by quotes is interpreted
33 # as a number if possible, otherwise as a string.
34 .if ${:U0}
35 .  error
36 .endif
37
38 # A non-zero number from a variable expression evaluates to true.
39 .if !${:U12345}
40 .  error
41 .endif
42
43 all: # nothing