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 Add another unit test for the :M mod...



details:   https://anonhg.NetBSD.org/src/rev/ec411b76ea4b
branches:  trunk
changeset: 461556:ec411b76ea4b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Nov 30 02:31:19 2019 +0000

description:
Add another unit test for the :M modifier

diffstat:

 usr.bin/make/unit-tests/varmod-edge.exp |   1 +
 usr.bin/make/unit-tests/varmod-edge.mk  |  17 ++++++++++++++++-
 2 files changed, 17 insertions(+), 1 deletions(-)

diffs (45 lines):

diff -r 2e68f0acf358 -r ec411b76ea4b usr.bin/make/unit-tests/varmod-edge.exp
--- a/usr.bin/make/unit-tests/varmod-edge.exp   Sat Nov 30 02:22:23 2019 +0000
+++ b/usr.bin/make/unit-tests/varmod-edge.exp   Sat Nov 30 02:31:19 2019 +0000
@@ -4,4 +4,5 @@
 ok M-nest-mix
 ok M-nest-brk
 ok M-pat-err
+ok M-bsbs
 exit status 0
diff -r 2e68f0acf358 -r ec411b76ea4b usr.bin/make/unit-tests/varmod-edge.mk
--- a/usr.bin/make/unit-tests/varmod-edge.mk    Sat Nov 30 02:22:23 2019 +0000
+++ b/usr.bin/make/unit-tests/varmod-edge.mk    Sat Nov 30 02:31:19 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-edge.mk,v 1.1 2019/11/30 00:38:51 rillig Exp $
+# $NetBSD: varmod-edge.mk,v 1.2 2019/11/30 02:31:19 rillig Exp $
 #
 # Tests for edge cases in variable modifiers.
 #
@@ -54,11 +54,26 @@
 # No error is reported though, and the pattern is closed implicitly.
 #
 # XXX: It is unexpected that no error is reported.
+# See str.c, function Str_Match.
 TESTS+=                M-pat-err
 INP.M-pat-err= [ [[ [[[
 MOD.M-pat-err= ${INP.M-pat-err:M${:U[[}}
 EXP.M-pat-err= [
 
+# The first backslash does not escape the second backslash.
+# Therefore, the second backslash escapes the parenthesis.
+# This means that the pattern ends there.
+# The final } in the output comes from the end of MOD.M-bsbs.
+#
+# If the first backslash were to escape the second backslash, the first
+# closing brace would match the opening parenthesis (see M-mixed), and
+# the second closing brace would be needed to close the variable.
+TESTS+=                M-bsbs
+INP.M-bsbs=    \( \(}
+MOD.M-bsbs=    ${INP.M-bsbs:M\\(}}
+EXP.M-bsbs=    \(}
+#EXP.M-bsbs=   \(      # If the first backslash were to escape ...
+
 all:
 .for test in ${TESTS}
 .  if ${MOD.${test}} == ${EXP.${test}}



Home | Main Index | Thread Index | Old Index