Home | History | Annotate | Line # | Download | only in unit-tests
      1  1.3  rillig # $NetBSD: cond-cmp-numeric-ne.mk,v 1.3 2023/09/07 05:36:33 rillig Exp $
      2  1.1  rillig #
      3  1.1  rillig # Tests for numeric comparisons with the != operator in .if conditions.
      4  1.1  rillig 
      5  1.1  rillig # When both sides are equal, the != operator always yields false.
      6  1.1  rillig .if 1 != 1
      7  1.2  rillig .  error
      8  1.1  rillig .endif
      9  1.1  rillig 
     10  1.1  rillig # This comparison yields the same result, whether numeric or character-based.
     11  1.1  rillig .if 1 != 2
     12  1.1  rillig .else
     13  1.2  rillig .  error
     14  1.1  rillig .endif
     15  1.1  rillig 
     16  1.1  rillig .if 2 != 1
     17  1.1  rillig .else
     18  1.2  rillig .  error
     19  1.1  rillig .endif
     20  1.1  rillig 
     21  1.1  rillig # Scientific notation is supported, as per strtod.
     22  1.1  rillig .if 2e7 != 2000e4
     23  1.2  rillig .  error
     24  1.1  rillig .endif
     25  1.1  rillig 
     26  1.1  rillig .if 2000e4 != 2e7
     27  1.2  rillig .  error
     28  1.1  rillig .endif
     29  1.1  rillig 
     30  1.1  rillig # Trailing zeroes after the decimal point are irrelevant for the numeric
     31  1.1  rillig # value.
     32  1.1  rillig .if 3.30000 != 3.3
     33  1.2  rillig .  error
     34  1.1  rillig .endif
     35  1.1  rillig 
     36  1.1  rillig .if 3.3 != 3.30000
     37  1.2  rillig .  error
     38  1.1  rillig .endif
     39  1.1  rillig 
     40  1.3  rillig # Numeric comparison works by parsing both sides
     41  1.1  rillig # as double, and then performing a normal comparison.  The range of double is
     42  1.1  rillig # typically 16 or 17 significant digits, therefore these two numbers seem to
     43  1.1  rillig # be equal.
     44  1.1  rillig .if 1.000000000000000001 != 1.000000000000000002
     45  1.2  rillig .  error
     46  1.1  rillig .endif
     47  1.1  rillig 
     48  1.1  rillig all:
     49  1.1  rillig 	@:;
     50