Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests make(1): add tests for parsing error...



details:   https://anonhg.NetBSD.org/src/rev/0424091bdead
branches:  trunk
changeset: 956545:0424091bdead
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Nov 01 13:28:50 2020 +0000

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

diffstat:

 usr.bin/make/unit-tests/varmod-to-separator.exp |  14 +++++++--
 usr.bin/make/unit-tests/varmod-to-separator.mk  |  35 ++++++++++++++++++++++--
 2 files changed, 41 insertions(+), 8 deletions(-)

diffs (84 lines):

diff -r f780dab2fb7f -r 0424091bdead usr.bin/make/unit-tests/varmod-to-separator.exp
--- a/usr.bin/make/unit-tests/varmod-to-separator.exp   Sun Nov 01 13:10:22 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-to-separator.exp   Sun Nov 01 13:28:50 2020 +0000
@@ -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
diff -r f780dab2fb7f -r 0424091bdead usr.bin/make/unit-tests/varmod-to-separator.mk
--- a/usr.bin/make/unit-tests/varmod-to-separator.mk    Sun Nov 01 13:10:22 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-to-separator.mk    Sun Nov 01 13:28:50 2020 +0000
@@ -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 @@
 .  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:
-       @:;



Home | Main Index | Thread Index | Old Index