xref: /freebsd/contrib/bmake/unit-tests/cond-op-not.mk (revision bdd1243df58e60e85101c09001d9812a789b6bc4)
1# $NetBSD: cond-op-not.mk,v 1.7 2021/01/19 17:49:13 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
58# A single exclamation mark is a parse error.
59.if !
60.  error
61.else
62.  error
63.endif
64
65all:
66	@:;
67