Home | History | Annotate | Line # | Download | only in unit-tests
cond-op-not.mk revision 1.8.2.1
      1  1.8.2.1  perseant # $NetBSD: cond-op-not.mk,v 1.8.2.1 2025/08/02 05:58:31 perseant Exp $
      2      1.1    rillig #
      3      1.5    rillig # Tests for the ! operator in .if conditions, which negates its argument.
      4      1.1    rillig 
      5      1.3    rillig # The exclamation mark negates its operand.
      6      1.3    rillig .if !1
      7      1.4    rillig .  error
      8      1.3    rillig .endif
      9      1.3    rillig 
     10      1.3    rillig # Exclamation marks can be chained.
     11      1.3    rillig # This doesn't happen in practice though.
     12      1.3    rillig .if !!!1
     13      1.4    rillig .  error
     14      1.3    rillig .endif
     15      1.3    rillig 
     16      1.3    rillig # The ! binds more tightly than the &&.
     17      1.3    rillig .if !!0 && 1
     18      1.4    rillig .  error
     19      1.3    rillig .endif
     20      1.1    rillig 
     21      1.6    rillig # The operator '==' binds more tightly than '!'.
     22      1.6    rillig # This is unusual since most other programming languages define the precedence
     23      1.6    rillig # to be the other way round.
     24      1.5    rillig .if !${:Uexpression} == "expression"
     25      1.5    rillig .  error
     26      1.5    rillig .endif
     27      1.5    rillig 
     28      1.5    rillig .if !${:U}
     29      1.8    rillig # expect+1: Not empty evaluates to true.
     30      1.5    rillig .  info Not empty evaluates to true.
     31      1.5    rillig .else
     32      1.5    rillig .  info Not empty evaluates to false.
     33      1.5    rillig .endif
     34      1.5    rillig 
     35      1.5    rillig .if !${:U }
     36      1.5    rillig .  info Not space evaluates to true.
     37      1.5    rillig .else
     38      1.8    rillig # expect+1: Not space evaluates to false.
     39      1.5    rillig .  info Not space evaluates to false.
     40      1.5    rillig .endif
     41      1.5    rillig 
     42      1.5    rillig .if !${:U0}
     43      1.8    rillig # expect+1: Not 0 evaluates to true.
     44      1.5    rillig .  info Not 0 evaluates to true.
     45      1.5    rillig .else
     46      1.5    rillig .  info Not 0 evaluates to false.
     47      1.5    rillig .endif
     48      1.5    rillig 
     49      1.5    rillig .if !${:U1}
     50      1.5    rillig .  info Not 1 evaluates to true.
     51      1.5    rillig .else
     52      1.8    rillig # expect+1: Not 1 evaluates to false.
     53      1.5    rillig .  info Not 1 evaluates to false.
     54      1.5    rillig .endif
     55      1.5    rillig 
     56      1.5    rillig .if !${:Uword}
     57      1.5    rillig .  info Not word evaluates to true.
     58      1.5    rillig .else
     59      1.8    rillig # expect+1: Not word evaluates to false.
     60      1.5    rillig .  info Not word evaluates to false.
     61      1.5    rillig .endif
     62      1.5    rillig 
     63      1.7    rillig # A single exclamation mark is a parse error.
     64  1.8.2.1  perseant # expect+1: Malformed conditional "!"
     65      1.7    rillig .if !
     66      1.7    rillig .  error
     67      1.7    rillig .else
     68      1.7    rillig .  error
     69      1.7    rillig .endif
     70      1.7    rillig 
     71      1.1    rillig all:
     72      1.1    rillig 	@:;
     73