Module Name:    src
Committed By:   rillig
Date:           Sun Nov  1 13:28:50 UTC 2020

Modified Files:
        src/usr.bin/make/unit-tests: varmod-to-separator.exp
            varmod-to-separator.mk

Log Message:
make(1): add tests for parsing errors in the :ts variable modifier


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-to-separator.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-to-separator.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-to-separator.exp
diff -u src/usr.bin/make/unit-tests/varmod-to-separator.exp:1.3 src/usr.bin/make/unit-tests/varmod-to-separator.exp:1.4
--- src/usr.bin/make/unit-tests/varmod-to-separator.exp:1.3	Sun Nov  1 11:50:11 2020
+++ src/usr.bin/make/unit-tests/varmod-to-separator.exp	Sun Nov  1 13:28:50 2020
@@ -1,11 +1,17 @@
 make: "varmod-to-separator.mk" line 106: warning: The separator \400 is accepted even though it is out of bounds.
 make: "varmod-to-separator.mk" line 118: warning: The separator \x100 is accepted even though it is out of bounds.
+make: Bad modifier `:ts\-300' for WORDS
+make: "varmod-to-separator.mk" line 124: Malformed conditional (${WORDS:[1..3]:ts\-300:tu})
+make: Bad modifier `:ts\8' for 1 2 3
+make: "varmod-to-separator.mk" line 132: Malformed conditional (${1 2 3:L:ts\8:tu})
+make: Bad modifier `:ts\100L' for 1 2 3
+make: "varmod-to-separator.mk" line 139: Malformed conditional (${1 2 3:L:ts\100L})
+make: Bad modifier `:ts\x40g' for 1 2 3
+make: "varmod-to-separator.mk" line 146: Malformed conditional (${1 2 3:L:ts\x40g})
 make: Bad modifier `:tx' for WORDS
-make: "varmod-to-separator.mk" line 124: Malformed conditional (${WORDS:tx} != "anything")
-make: "varmod-to-separator.mk" line 128: Parsing continues here.
+make: "varmod-to-separator.mk" line 154: Malformed conditional (${WORDS:tx} != "anything")
 make: Bad modifier `:t\X' for WORDS
-make: "varmod-to-separator.mk" line 132: Malformed conditional (${WORDS:t\X} != "anything")
-make: "varmod-to-separator.mk" line 135: Parsing continues here.
+make: "varmod-to-separator.mk" line 161: Malformed conditional (${WORDS:t\X} != "anything")
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-to-separator.mk
diff -u src/usr.bin/make/unit-tests/varmod-to-separator.mk:1.4 src/usr.bin/make/unit-tests/varmod-to-separator.mk:1.5
--- src/usr.bin/make/unit-tests/varmod-to-separator.mk:1.4	Sun Nov  1 11:50:11 2020
+++ src/usr.bin/make/unit-tests/varmod-to-separator.mk	Sun Nov  1 13:28:50 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-to-separator.mk,v 1.4 2020/11/01 11:50:11 rillig Exp $
+# $NetBSD: varmod-to-separator.mk,v 1.5 2020/11/01 13:28:50 rillig Exp $
 #
 # Tests for the :ts variable modifier, which joins the words of the variable
 # using an arbitrary character as word separator.
@@ -120,19 +120,46 @@ WORDS=	one two three four five six
 .  warning The separator \x100 is accepted even though it is out of bounds.
 .endif
 
+# Negative numbers are not allowed for the separator character.
+.if ${WORDS:[1..3]:ts\-300:tu}
+.  warning The separator \-300 is accepted even though it is negative.
+.else
+.  warning The separator \-300 is accepted even though it is negative.
+.endif
+
+# The character number is interpreted as octal number by default.
+# The digit '8' is not an octal digit though.
+.if ${1 2 3:L:ts\8:tu}
+.  warning The separator \8 is accepted even though it is not octal.
+.else
+.  warning The separator \8 is accepted even though it is not octal.
+.endif
+
+# Trailing characters after the octal character number are rejected.
+.if ${1 2 3:L:ts\100L}
+.  warning The separator \100L is accepted even though it contains an 'L'.
+.else
+.  warning The separator \100L is accepted even though it contains an 'L'.
+.endif
+
+# Trailing characters after the hexadecimal character number are rejected.
+.if ${1 2 3:L:ts\x40g}
+.  warning The separator \x40g is accepted even though it contains a 'g'.
+.else
+.  warning The separator \x40g is accepted even though it contains a 'g'.
+.endif
+
+
 # In the :t modifier, the :t must be followed by any of A, l, s, u.
 .if ${WORDS:tx} != "anything"
 .  info This line is not reached because of the malformed condition.
 .  info If this line were reached, it would be visible in the -dcpv log.
 .endif
-.info Parsing continues here.
 
 # After the backslash, only n, t, an octal number, or x and a hexadecimal
 # number are allowed.
 .if ${WORDS:t\X} != "anything"
 .  info This line is not reached.
 .endif
-.info Parsing continues here.
 
 all:
-	@:;

Reply via email to