1# $NetBSD: cond-op-and.mk,v 1.11 2024/08/06 18:00:17 rillig Exp $ 2# 3# Tests for the && operator in .if conditions. 4 5.if 0 && 0 6. error 7.endif 8 9.if 1 && 0 10. error 11.endif 12 13.if 0 && 1 14. error 15.endif 16 17.if !(1 && 1) 18. error 19.endif 20 21 22# The right-hand side is not evaluated since the left-hand side is already 23# false. 24.if 0 && ${UNDEF} 25.endif 26 27# When an outer condition makes the inner '&&' condition irrelevant, neither 28# of its operands is evaluated. 29.if 1 || (${UNDEF} && ${UNDEF}) 30.endif 31 32# Test combinations of outer '||' with inner '&&', to ensure that the operands 33# of the inner '&&' are only evaluated if necessary. 34DEF= defined 35# expect+1: Malformed conditional '0 || (${DEF} && ${UNDEF})' 36.if 0 || (${DEF} && ${UNDEF}) 37.endif 38.if 0 || (!${DEF} && ${UNDEF}) 39.endif 40# expect+1: Malformed conditional '0 || (${UNDEF} && ${UNDEF})' 41.if 0 || (${UNDEF} && ${UNDEF}) 42.endif 43# expect+1: Malformed conditional '0 || (!${UNDEF} && ${UNDEF})' 44.if 0 || (!${UNDEF} && ${UNDEF}) 45.endif 46.if 1 || (${DEF} && ${UNDEF}) 47.endif 48.if 1 || (!${DEF} && ${UNDEF}) 49.endif 50.if 1 || (${UNDEF} && ${UNDEF}) 51.endif 52.if 1 || (!${UNDEF} && ${UNDEF}) 53.endif 54 55 56# The && operator may be abbreviated as &. This is not widely known though 57# and is also not documented in the manual page. 58 59# expect+1: Unknown operator '&' 60.if 0 & 0 61. error 62.else 63. error 64.endif 65# expect+1: Unknown operator '&' 66.if 1 & 0 67. error 68.else 69. error 70.endif 71# expect+1: Unknown operator '&' 72.if 0 & 1 73. error 74.else 75. error 76.endif 77# expect+1: Unknown operator '&' 78.if !(1 & 1) 79. error 80.else 81. error 82.endif 83 84# There is no operator '&&&'. The first two '&&' form an operator, the third 85# '&' forms the next (incomplete) token. 86# expect+1: Unknown operator '&' 87.if 0 &&& 0 88. error 89.else 90. error 91.endif 92 93# The '&&' operator must be preceded by whitespace, otherwise it becomes part 94# of the preceding bare word. The condition starts with a digit and is thus 95# parsed as '"1&&" != "" && 1'. 96.if 1&& && 1 97.else 98. error 99.endif 100