1# $NetBSD: varmod-order-numeric.mk,v 1.5 2021/08/03 04:46:49 rillig Exp $ 2# 3# Tests for the variable modifiers ':On', which returns the words, sorted in 4# ascending numeric order, and for ':Orn' and ':Onr', which additionally 5# reverse the order. 6# 7# The variable modifiers ':On', ':Onr' and ':Orn' were added in var.c 1.939 8# from 2021-07-30. 9 10# This list contains only 32-bit numbers since the make code needs to conform 11# to C90, which does not provide integer types larger than 32 bit. It uses 12# 'long long' by default, but that type is overridable if necessary to support 13# older environments. 14# 15# To get 53-bit integers even in C90, it would be possible to switch to 16# 'double' instead, but that would allow floating-point numbers as well, which 17# is out of scope for this variable modifier. 18NUMBERS= 3 5 7 1 42 -42 5K -3m 1M 1k -2G 19 20.if ${NUMBERS:On} != "-2G -3m -42 1 3 5 7 42 1k 5K 1M" 21. error ${NUMBERS:On} 22.endif 23 24.if ${NUMBERS:Orn} != "1M 5K 1k 42 7 5 3 1 -42 -3m -2G" 25. error ${NUMBERS:Orn} 26.endif 27 28# Both ':Onr' and ':Orn' have the same effect. 29.if ${NUMBERS:Onr} != "1M 5K 1k 42 7 5 3 1 -42 -3m -2G" 30. error ${NUMBERS:Onr} 31.endif 32 33# Duplicate numbers are preserved in the output. In this case the 34# equal-valued numbers are spelled the same, so they are indistinguishable in 35# the output. 36DUPLICATES= 3 1 2 2 1 1 # https://oeis.org/A034002 37.if ${DUPLICATES:On} != "1 1 1 2 2 3" 38. error ${DUPLICATES:On} 39.endif 40 41# If there are several numbers that have the same integer value, they are 42# returned in unspecified order. 43SAME_VALUE:= ${:U 79 80 0x0050 81 :On} 44.if ${SAME_VALUE} != "79 80 0x0050 81" && ${SAME_VALUE} != "79 0x0050 80 81" 45. error ${SAME_VALUE} 46.endif 47 48# Hexadecimal and octal numbers are supported as well. 49MIXED_BASE= 0 010 0x7 9 50.if ${MIXED_BASE:On} != "0 0x7 010 9" 51. error ${MIXED_BASE:On} 52.endif 53 54all: 55