1# $NetBSD: cond-op-or.mk,v 1.9 2023/06/01 20:56:35 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# true. 24.if 1 || ${UNDEF} 25.endif 26 27# When an outer condition makes the inner '||' condition irrelevant, neither 28# of its operands must be evaluated. This had been wrong in cond.c 1.283 from 29# 2021-12-09 and was reverted in cond.c 1.284 an hour later. 30.if 0 && (!defined(UNDEF) || ${UNDEF}) 31.endif 32 33# Test combinations of outer '&&' with inner '||', to ensure that the operands 34# of the inner '||' is only evaluated if necessary. 35DEF= defined 36.if 0 && (${DEF} || ${UNDEF}) 37.endif 38.if 0 && (!${DEF} || ${UNDEF}) 39.endif 40.if 0 && (${UNDEF} || ${UNDEF}) 41.endif 42.if 0 && (!${UNDEF} || ${UNDEF}) 43.endif 44.if 1 && (${DEF} || ${UNDEF}) 45.endif 46# expect+1: Malformed conditional (1 && (!${DEF} || ${UNDEF}) 47.if 1 && (!${DEF} || ${UNDEF}) 48.endif 49# expect+1: Malformed conditional (1 && (${UNDEF} || ${UNDEF}) 50.if 1 && (${UNDEF} || ${UNDEF}) 51.endif 52# expect+1: Malformed conditional (1 && (!${UNDEF} || ${UNDEF}) 53.if 1 && (!${UNDEF} || ${UNDEF}) 54.endif 55 56 57# The || operator may be abbreviated as |. This is not widely known though 58# and is also not documented in the manual page. 59 60.if 0 | 0 61. error 62.endif 63.if !(1 | 0) 64. error 65.endif 66.if !(0 | 1) 67. error 68.endif 69.if !(1 | 1) 70. error 71.endif 72 73# There is no operator |||. 74# expect+1: Malformed conditional (0 ||| 0) 75.if 0 ||| 0 76. error 77.endif 78 79all: 80 @:; 81