Home | History | Annotate | Line # | Download | only in unit-tests
cond-op-and.mk revision 1.6
      1 # $NetBSD: cond-op-and.mk,v 1.6 2021/12/10 19:14: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 # false.
     24 .if 0 && ${UNDEF}
     25 .endif
     26 
     27 # When an outer condition makes the inner '&&' condition irrelevant, neither
     28 # of its operands must be evaluated.
     29 #
     30 .if 1 || (${UNDEF} && ${UNDEF})
     31 .endif
     32 
     33 # Test combinations of outer '||' with inner '&&', to ensure that the operands
     34 # of the inner '&&' are only evaluated if necessary.
     35 DEF=	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 .if 1 || (!${DEF} && ${UNDEF})
     47 .endif
     48 .if 1 || (${UNDEF} && ${UNDEF})
     49 .endif
     50 .if 1 || (!${UNDEF} && ${UNDEF})
     51 .endif
     52 
     53 
     54 # The && operator may be abbreviated as &.  This is not widely known though
     55 # and is also not documented in the manual page.
     56 
     57 .if 0 & 0
     58 .  error
     59 .endif
     60 .if 1 & 0
     61 .  error
     62 .endif
     63 .if 0 & 1
     64 .  error
     65 .endif
     66 .if !(1 & 1)
     67 .  error
     68 .endif
     69 
     70 # There is no operator &&&.
     71 .if 0 &&& 0
     72 .  error
     73 .endif
     74 
     75 all:
     76 	@:;
     77