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