1# $NetBSD: varmod-order.mk,v 1.14 2024/07/05 18:59:33 rillig Exp $ 2# 3# Tests for the :O variable modifier and its variants, which either sort the 4# words of the value or shuffle them. 5 6WORDS= one two three four five six seven eight nine ten 7NUMBERS= 8 5 4 9 1 7 6 10 3 2 # in English alphabetical order 8 9.if ${WORDS:O} != "eight five four nine one seven six ten three two" 10. error ${WORDS:O} 11.endif 12 13# Unknown modifier "OX" 14# FIXME: The error message "Undefined variable" is wrong. 15# expect+2: Undefined variable "${WORDS:OX" 16# expect+1: while evaluating variable "WORDS" with value "one two three four five six seven eight nine ten": Bad modifier ":OX" 17_:= ${WORDS:OX} 18 19# Unknown modifier "OxXX" 20# FIXME: The error message "Undefined variable" is wrong. 21# expect+2: Undefined variable "${WORDS:Ox" 22# expect+1: while evaluating variable "WORDS" with value "one two three four five six seven eight nine ten": Bad modifier ":OxXX" 23_:= ${WORDS:OxXX} 24 25# Missing closing brace, to cover the error handling code. 26# expect+1: while evaluating variable "WORDS" with value "eight five four nine one seven six ten three two": Unclosed expression, expecting '}' for modifier "O" 27_:= ${WORDS:O 28# expect+1: while evaluating variable "NUMBERS" with value "1 2 3 4 5 6 7 8 9 10": Unclosed expression, expecting '}' for modifier "On" 29_:= ${NUMBERS:On 30# expect+1: while evaluating variable "NUMBERS" with value "10 9 8 7 6 5 4 3 2 1": Unclosed expression, expecting '}' for modifier "Onr" 31_:= ${NUMBERS:Onr 32 33# Shuffling numerically doesn't make sense, so don't allow 'x' and 'n' to be 34# combined. 35# 36# expect+2: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Oxn" 37# expect+1: Malformed conditional (${NUMBERS:Oxn}) 38.if ${NUMBERS:Oxn} 39. error 40.else 41. error 42.endif 43 44# Extra characters after ':On' are detected and diagnosed. 45# 46# expect+2: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":On_typo" 47# expect+1: Malformed conditional (${NUMBERS:On_typo}) 48.if ${NUMBERS:On_typo} 49. error 50.else 51. error 52.endif 53 54# Extra characters after ':Onr' are detected and diagnosed. 55# 56# expect+2: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Onr_typo" 57# expect+1: Malformed conditional (${NUMBERS:Onr_typo}) 58.if ${NUMBERS:Onr_typo} 59. error 60.else 61. error 62.endif 63 64# Extra characters after ':Orn' are detected and diagnosed. 65# 66# expect+2: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Orn_typo" 67# expect+1: Malformed conditional (${NUMBERS:Orn_typo}) 68.if ${NUMBERS:Orn_typo} 69. error 70.else 71. error 72.endif 73 74# Repeating the 'n' is not supported. In the typical use cases, the sorting 75# criteria are fixed, not computed, therefore allowing this redundancy does 76# not make sense. 77# 78# expect+2: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Onn" 79# expect+1: Malformed conditional (${NUMBERS:Onn}) 80.if ${NUMBERS:Onn} 81. error 82.else 83. error 84.endif 85 86# Repeating the 'r' is not supported as well, for the same reasons as above. 87# 88# expect+2: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Onrr" 89# expect+1: Malformed conditional (${NUMBERS:Onrr}) 90.if ${NUMBERS:Onrr} 91. error 92.else 93. error 94.endif 95 96# Repeating the 'r' is not supported as well, for the same reasons as above. 97# 98# expect+2: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Orrn" 99# expect+1: Malformed conditional (${NUMBERS:Orrn}) 100.if ${NUMBERS:Orrn} 101. error 102.else 103. error 104.endif 105 106 107# If a modifier that starts with ':O' is not one of the known sort or shuffle 108# forms, it is a parse error. Several other modifiers such as ':H' or ':u' 109# fall back to the SysV modifier, for example, ':H=new' is not the standard 110# ':H' modifier but instead replaces a trailing 'H' with 'new' in each word. 111# There is no such fallback for the ':O' modifiers. 112SWITCH= On 113# expect+2: while evaluating variable "SWITCH" with value "On": Bad modifier ":On=Off" 114# expect+1: Malformed conditional (${SWITCH:On=Off} != "Off") 115.if ${SWITCH:On=Off} != "Off" 116. error 117.else 118. error 119.endif 120 121all: 122