]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - unit-tests/cond-short.mk
Import bmake-20200629
[FreeBSD/FreeBSD.git] / unit-tests / cond-short.mk
1 # $NetBSD: cond-short.mk,v 1.2 2020/06/28 11:06:26 rillig Exp $
2 #
3 # Demonstrates that in conditions, the right-hand side of an && or ||
4 # is only evaluated if it can actually influence the result.
5 #
6 # Between 2015-10-11 and 2020-06-28, the right-hand side of an && or ||
7 # operator was always evaluated, which was wrong.
8 #
9
10 # The && operator.
11
12 .if 0 && ${echo "unexpected and" 1>&2 :L:sh}
13 .endif
14
15 .if 1 && ${echo "expected and" 1>&2 :L:sh}
16 .endif
17
18 .if 0 && exists(nonexistent${echo "unexpected and exists" 1>&2 :L:sh})
19 .endif
20
21 .if 1 && exists(nonexistent${echo "expected and exists" 1>&2 :L:sh})
22 .endif
23
24 .if 0 && empty(${echo "unexpected and empty" 1>&2 :L:sh})
25 .endif
26
27 .if 1 && empty(${echo "expected and empty" 1>&2 :L:sh})
28 .endif
29
30 # The || operator.
31
32 .if 1 || ${echo "unexpected or" 1>&2 :L:sh}
33 .endif
34
35 .if 0 || ${echo "expected or" 1>&2 :L:sh}
36 .endif
37
38 .if 1 || exists(nonexistent${echo "unexpected or exists" 1>&2 :L:sh})
39 .endif
40
41 .if 0 || exists(nonexistent${echo "expected or exists" 1>&2 :L:sh})
42 .endif
43
44 .if 1 || empty(${echo "unexpected or empty" 1>&2 :L:sh})
45 .endif
46
47 .if 0 || empty(${echo "expected or empty" 1>&2 :L:sh})
48 .endif
49
50 # Unreachable nested conditions are skipped completely as well.
51
52 .if 0
53 .  if ${echo "unexpected nested and" 1>&2 :L:sh}
54 .  endif
55 .endif
56
57 .if 1
58 .elif ${echo "unexpected nested or" 1>&2 :L:sh}
59 .endif
60
61 all:
62         @:;: