Tue Sep 27 19:18:45 2022 UTC ()
tests/make: add tests for legacy local variables and sorting


(rillig)
diff -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-scope-local-legacy.exp
diff -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-scope-local-legacy.mk
diff -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-order-numeric.mk

cvs diff -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-scope-local-legacy.exp (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/var-scope-local-legacy.exp 2022/01/23 16:25:54 1.1
+++ src/usr.bin/make/unit-tests/var-scope-local-legacy.exp 2022/09/27 19:18:45 1.2

cvs diff -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-scope-local-legacy.mk (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/var-scope-local-legacy.mk 2022/01/23 16:25:54 1.1
+++ src/usr.bin/make/unit-tests/var-scope-local-legacy.mk 2022/09/27 19:18:45 1.2
@@ -1,8 +1,17 @@ @@ -1,8 +1,17 @@
1# $NetBSD: var-scope-local-legacy.mk,v 1.1 2022/01/23 16:25:54 rillig Exp $ 1# $NetBSD: var-scope-local-legacy.mk,v 1.2 2022/09/27 19:18:45 rillig Exp $
2# 2#
3# Tests for legacy target-local variables, such as ${<F} or ${@D}. 3# Tests for legacy target-local variables, such as ${<F} or ${@D}.
4 4
5# TODO: Implementation 5all: .PHONY
6 6 # Only variables of length 2 can be legacy, this one cannot.
7all: 7 : LEN4=${LEN4:Uundef}_
8 @:; 8 # The second character of the name must be 'D' or 'F'.
 9 : XY=${XY:Uundef}_
 10 # The first character must name one of the 7 predefined local
 11 # variables, 'A' is not such a character.
 12 : AF=${AF:Uundef}_
 13 # The variable '.MEMBER' is undefined, therefore '%D' and '%F' are
 14 # undefined as well.
 15 : %D=${%D:Uundef}_ %F=${%F:Uundef}_
 16 # The directory name of the target is '.', its basename is 'all'.
 17 : @D=${@D:Uundef}_ @F=${@F:Uundef}_

cvs diff -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-order-numeric.mk (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/varmod-order-numeric.mk 2022/02/09 21:09:24 1.7
+++ src/usr.bin/make/unit-tests/varmod-order-numeric.mk 2022/09/27 19:18:45 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: varmod-order-numeric.mk,v 1.7 2022/02/09 21:09:24 rillig Exp $ 1# $NetBSD: varmod-order-numeric.mk,v 1.8 2022/09/27 19:18:45 rillig Exp $
2# 2#
3# Tests for the variable modifiers ':On', which returns the words, sorted in 3# Tests for the variable modifiers ':On', which returns the words, sorted in
4# ascending numeric order, and for ':Orn' and ':Onr', which additionally 4# ascending numeric order, and for ':Orn' and ':Onr', which additionally
5# reverse the order. 5# reverse the order.
6# 6#
7# The variable modifiers ':On', ':Onr' and ':Orn' were added in var.c 1.939 7# The variable modifiers ':On', ':Onr' and ':Orn' were added in var.c 1.939
8# from 2021-07-30. 8# from 2021-07-30.
9 9
10# This list contains only 32-bit numbers since the make code needs to conform 10# This list contains only 32-bit numbers since the make code needs to conform
11# to C90, which does not necessarily provide integer types larger than 32 bit. 11# to C90, which does not necessarily provide integer types larger than 32 bit.
12# Make uses 'long long' for C99 or later, and 'long' for older C versions. 12# Make uses 'long long' for C99 or later, and 'long' for older C versions.
13# 13#
14# To get 53-bit integers even in C90, it would be possible to switch to 14# To get 53-bit integers even in C90, it would be possible to switch to
@@ -40,14 +40,20 @@ DUPLICATES= 3 1 2 2 1 1 # subsequence of @@ -40,14 +40,20 @@ DUPLICATES= 3 1 2 2 1 1 # subsequence of
40# If there are several numbers that have the same integer value, they are 40# If there are several numbers that have the same integer value, they are
41# returned in unspecified order. 41# returned in unspecified order.
42SAME_VALUE:= ${:U 79 80 0x0050 81 :On} 42SAME_VALUE:= ${:U 79 80 0x0050 81 :On}
43.if ${SAME_VALUE} != "79 80 0x0050 81" && ${SAME_VALUE} != "79 0x0050 80 81" 43.if ${SAME_VALUE} != "79 80 0x0050 81" && ${SAME_VALUE} != "79 0x0050 80 81"
44. error ${SAME_VALUE} 44. error ${SAME_VALUE}
45.endif 45.endif
46 46
47# Hexadecimal and octal numbers can be sorted as well. 47# Hexadecimal and octal numbers can be sorted as well.
48MIXED_BASE= 0 010 0x7 9 48MIXED_BASE= 0 010 0x7 9
49.if ${MIXED_BASE:On} != "0 0x7 010 9" 49.if ${MIXED_BASE:On} != "0 0x7 010 9"
50. error ${MIXED_BASE:On} 50. error ${MIXED_BASE:On}
51.endif 51.endif
52 52
 53# The measurement units for suffixes are k, M, G, but not T.
 54# The string '3T' evaluates to 3, the string 'x' evaluates as '0'.
 55.if ${4 3T 2M x:L:On} != "x 3T 4 2M"
 56. error
 57.endif
 58
53all: 59all: