xref: /freebsd/contrib/bmake/unit-tests/cond-op-not.mk (revision cfd6422a5217410fbd66f7a7a8a64d9d85e61229)
1# $NetBSD: cond-op-not.mk,v 1.6 2020/11/15 14:58:14 rillig Exp $
2#
3# Tests for the ! operator in .if conditions, which negates its argument.
4
5# The exclamation mark negates its operand.
6.if !1
7.  error
8.endif
9
10# Exclamation marks can be chained.
11# This doesn't happen in practice though.
12.if !!!1
13.  error
14.endif
15
16# The ! binds more tightly than the &&.
17.if !!0 && 1
18.  error
19.endif
20
21# The operator '==' binds more tightly than '!'.
22# This is unusual since most other programming languages define the precedence
23# to be the other way round.
24.if !${:Uexpression} == "expression"
25.  error
26.endif
27
28.if !${:U}
29.  info Not empty evaluates to true.
30.else
31.  info Not empty evaluates to false.
32.endif
33
34.if !${:U }
35.  info Not space evaluates to true.
36.else
37.  info Not space evaluates to false.
38.endif
39
40.if !${:U0}
41.  info Not 0 evaluates to true.
42.else
43.  info Not 0 evaluates to false.
44.endif
45
46.if !${:U1}
47.  info Not 1 evaluates to true.
48.else
49.  info Not 1 evaluates to false.
50.endif
51
52.if !${:Uword}
53.  info Not word evaluates to true.
54.else
55.  info Not word evaluates to false.
56.endif
57
58all:
59	@:;
60