varmod-order-numeric.mk revision 1.4 1 # $NetBSD: varmod-order-numeric.mk,v 1.4 2021/07/31 20:55:46 rillig Exp $
2 #
3 # Tests for the :On variable modifier, which returns the words, sorted in
4 # ascending numeric order.
5
6 # This list contains only 32-bit numbers since the make code needs to conform
7 # to C90, which does not provide integer types larger than 32 bit. It uses
8 # 'long long' by default, but that type is overridable if necessary.
9 # To get 53-bit integers even in C90, it would be possible to switch to
10 # 'double' instead, but that would allow floating-point numbers as well, which
11 # is out of scope for this variable modifier.
12 NUMBERS= 3 5 7 1 42 -42 5K -3m 1M 1k -2G
13
14 .if ${NUMBERS:On} != "-2G -3m -42 1 3 5 7 42 1k 5K 1M"
15 . error ${NUMBERS:On}
16 .endif
17
18 .if ${NUMBERS:Orn} != "1M 5K 1k 42 7 5 3 1 -42 -3m -2G"
19 . error ${NUMBERS:Orn}
20 .endif
21
22 # Both ':Onr' and ':Orn' have the same effect.
23 .if ${NUMBERS:Onr} != "1M 5K 1k 42 7 5 3 1 -42 -3m -2G"
24 . error ${NUMBERS:Onr}
25 .endif
26
27 # If there are several numbers that have the same integer value, they are
28 # returned in unspecified order.
29 SAME_VALUE:= ${:U 79 80 0x0050 81 :On}
30 .if ${SAME_VALUE} != "79 80 0x0050 81" && ${SAME_VALUE} != "79 0x0050 80 81"
31 . error ${SAME_VALUE}
32 .endif
33
34 # Hexadecimal and octal numbers are supported as well.
35 OCTAL= 0 010 0x7 9
36 .if ${OCTAL:On} != "0 0x7 010 9"
37 . error ${OCTAL:On}
38 .endif
39
40 all:
41