Home | History | Annotate | Line # | Download | only in unit-tests
cond-cmp-unary.mk revision 1.1
      1  1.1  rillig # $NetBSD: cond-cmp-unary.mk,v 1.1 2020/09/14 06:22:59 rillig Exp $
      2  1.1  rillig #
      3  1.1  rillig # Tests for unary comparisons in .if conditions, that is, comparisons with
      4  1.1  rillig # a single operand.  If the operand is a number, it is compared to zero,
      5  1.1  rillig # if it is a string, it is tested for emptiness.
      6  1.1  rillig 
      7  1.1  rillig # The number 0 evaluates to false.
      8  1.1  rillig .if 0
      9  1.1  rillig .  error
     10  1.1  rillig .endif
     11  1.1  rillig 
     12  1.1  rillig # Any other number evaluates to true.
     13  1.1  rillig .if !12345
     14  1.1  rillig .  error
     15  1.1  rillig .endif
     16  1.1  rillig 
     17  1.1  rillig # The empty string evaluates to false.
     18  1.1  rillig .if ""
     19  1.1  rillig .  error
     20  1.1  rillig .endif
     21  1.1  rillig 
     22  1.1  rillig # Any other string evaluates to true.
     23  1.1  rillig .if !"0"
     24  1.1  rillig .  error
     25  1.1  rillig .endif
     26  1.1  rillig 
     27  1.1  rillig # The empty string may come from a variable expression.
     28  1.1  rillig .if ${:U}
     29  1.1  rillig .  error
     30  1.1  rillig .endif
     31  1.1  rillig 
     32  1.1  rillig # A variable expression that is not surrounded by quotes is interpreted
     33  1.1  rillig # as a number if possible, otherwise as a string.
     34  1.1  rillig .if ${:U0}
     35  1.1  rillig .  error
     36  1.1  rillig .endif
     37  1.1  rillig 
     38  1.1  rillig # A non-zero number from a variable expression evaluates to true.
     39  1.1  rillig .if !${:U12345}
     40  1.1  rillig .  error
     41  1.1  rillig .endif
     42  1.1  rillig 
     43  1.1  rillig all: # nothing
     44