Home | History | Annotate | Line # | Download | only in unit-tests
cond-token-number.mk revision 1.4
      1  1.4  rillig # $NetBSD: cond-token-number.mk,v 1.4 2020/11/08 22:28:05 rillig Exp $
      2  1.1  rillig #
      3  1.2  rillig # Tests for number tokens in .if conditions.
      4  1.1  rillig 
      5  1.3  rillig .if 0
      6  1.3  rillig .  error
      7  1.3  rillig .endif
      8  1.1  rillig 
      9  1.3  rillig # Even though -0 is a number and would be accepted by strtod, it is not
     10  1.3  rillig # accepted by the condition parser.
     11  1.3  rillig #
     12  1.3  rillig # See the ch_isdigit call in CondParser_String.
     13  1.3  rillig .if -0
     14  1.3  rillig .  error
     15  1.3  rillig .endif
     16  1.3  rillig 
     17  1.3  rillig # Even though +0 is a number and would be accepted by strtod, it is not
     18  1.3  rillig # accepted by the condition parser.
     19  1.3  rillig #
     20  1.3  rillig # See the ch_isdigit call in CondParser_String.
     21  1.3  rillig .if +0
     22  1.3  rillig .  error
     23  1.3  rillig .endif
     24  1.3  rillig 
     25  1.3  rillig # Even though -1 is a number and would be accepted by strtod, it is not
     26  1.3  rillig # accepted by the condition parser.
     27  1.3  rillig #
     28  1.3  rillig # See the ch_isdigit call in CondParser_String.
     29  1.3  rillig .if !-1
     30  1.3  rillig .  error
     31  1.3  rillig .endif
     32  1.3  rillig 
     33  1.3  rillig # Even though +1 is a number and would be accepted by strtod, it is not
     34  1.3  rillig # accepted by the condition parser.
     35  1.3  rillig #
     36  1.3  rillig # See the ch_isdigit call in CondParser_String.
     37  1.3  rillig .if !+1
     38  1.3  rillig .  error
     39  1.3  rillig .endif
     40  1.3  rillig 
     41  1.3  rillig # When the number comes from a variable expression though, it may be signed.
     42  1.3  rillig # XXX: This is inconsistent.
     43  1.3  rillig .if ${:U+0}
     44  1.3  rillig .  error
     45  1.3  rillig .endif
     46  1.3  rillig 
     47  1.3  rillig # When the number comes from a variable expression though, it may be signed.
     48  1.3  rillig # XXX: This is inconsistent.
     49  1.3  rillig .if !${:U+1}
     50  1.3  rillig .  error
     51  1.3  rillig .endif
     52  1.3  rillig 
     53  1.4  rillig # Hexadecimal numbers are accepted.
     54  1.4  rillig .if 0x0
     55  1.4  rillig .  error
     56  1.4  rillig .endif
     57  1.4  rillig .if 0x1
     58  1.4  rillig .else
     59  1.4  rillig .  error
     60  1.4  rillig .endif
     61  1.4  rillig 
     62  1.4  rillig # This is not a hexadecimal number, even though it has an x.
     63  1.4  rillig # It is interpreted as a string instead, effectively meaning defined(3x4).
     64  1.4  rillig .if 3x4
     65  1.4  rillig .else
     66  1.4  rillig .  error
     67  1.4  rillig .endif
     68  1.4  rillig 
     69  1.3  rillig # Ensure that parsing continues until here.
     70  1.3  rillig .info End of the tests.
     71  1.3  rillig 
     72  1.3  rillig all: # nothing
     73