1# $NetBSD: cond-op-not.mk,v 1.8 2023/06/01 20:56:35 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# expect+1: Not empty evaluates to true.
30.  info Not empty evaluates to true.
31.else
32.  info Not empty evaluates to false.
33.endif
34
35.if !${:U }
36.  info Not space evaluates to true.
37.else
38# expect+1: Not space evaluates to false.
39.  info Not space evaluates to false.
40.endif
41
42.if !${:U0}
43# expect+1: Not 0 evaluates to true.
44.  info Not 0 evaluates to true.
45.else
46.  info Not 0 evaluates to false.
47.endif
48
49.if !${:U1}
50.  info Not 1 evaluates to true.
51.else
52# expect+1: Not 1 evaluates to false.
53.  info Not 1 evaluates to false.
54.endif
55
56.if !${:Uword}
57.  info Not word evaluates to true.
58.else
59# expect+1: Not word evaluates to false.
60.  info Not word evaluates to false.
61.endif
62
63# A single exclamation mark is a parse error.
64# expect+1: Malformed conditional (!)
65.if !
66.  error
67.else
68.  error
69.endif
70
71all:
72	@:;
73