varmod-order.mk revision 1.19 1 # $NetBSD: varmod-order.mk,v 1.19 2025/03/29 23:50:07 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
6 WORDS= one two three four five six seven eight nine ten
7 NUMBERS= 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 # expect+1: Unknown modifier ":OX"
14 _:= ${WORDS:OX}
15
16 # expect+1: Unknown modifier ":OxXX"
17 _:= ${WORDS:OxXX}
18
19 # expect+1: Unclosed expression, expecting '}' for modifier "O"
20 _:= ${WORDS:O
21 # expect+1: Unclosed expression, expecting '}' for modifier "On"
22 _:= ${NUMBERS:On
23 # expect+1: Unclosed expression, expecting '}' for modifier "Onr"
24 _:= ${NUMBERS:Onr
25
26 # Shuffling numerically doesn't make sense, so don't allow 'x' and 'n' to be
27 # combined.
28 #
29 # expect+1: Unknown modifier ":Oxn"
30 .if ${NUMBERS:Oxn}
31 . error
32 .else
33 . error
34 .endif
35
36 # Extra characters after ':On' are detected and diagnosed.
37 #
38 # expect+1: Unknown modifier ":On_typo"
39 .if ${NUMBERS:On_typo}
40 . error
41 .else
42 . error
43 .endif
44
45 # Extra characters after ':Onr' are detected and diagnosed.
46 #
47 # expect+1: Unknown modifier ":Onr_typo"
48 .if ${NUMBERS:Onr_typo}
49 . error
50 .else
51 . error
52 .endif
53
54 # Extra characters after ':Orn' are detected and diagnosed.
55 #
56 # expect+1: Unknown modifier ":Orn_typo"
57 .if ${NUMBERS:Orn_typo}
58 . error
59 .else
60 . error
61 .endif
62
63 # Repeating the 'n' is not supported. In the typical use cases, the sorting
64 # criteria are fixed, not computed, therefore allowing this redundancy does
65 # not make sense.
66 #
67 # expect+1: Unknown modifier ":Onn"
68 .if ${NUMBERS:Onn}
69 . error
70 .else
71 . error
72 .endif
73
74 # Repeating the 'r' is not supported as well, for the same reasons as above.
75 #
76 # expect+1: Unknown modifier ":Onrr"
77 .if ${NUMBERS:Onrr}
78 . error
79 .else
80 . error
81 .endif
82
83 # Repeating the 'r' is not supported as well, for the same reasons as above.
84 #
85 # expect+1: Unknown modifier ":Orrn"
86 .if ${NUMBERS:Orrn}
87 . error
88 .else
89 . error
90 .endif
91
92
93 # If a modifier that starts with ':O' is not one of the known sort or shuffle
94 # forms, fall back to the SysV modifier.
95 SWITCH= On
96 .if ${SWITCH:On=Off} != "Off"
97 . error
98 .endif
99
100 all:
101