Source-Changes-HG archive

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

[src/trunk]: src/tests/bin/sh Add a few more sub-tests to the $'...' syntax t...



details:   https://anonhg.NetBSD.org/src/rev/b8d7c7737097
branches:  trunk
changeset: 355877:b8d7c7737097
user:      kre <kre%NetBSD.org@localhost>
date:      Sat Aug 19 21:18:47 2017 +0000

description:
Add a few more sub-tests to the $'...' syntax tests.
Remove dome debug noise accidentally left in when the test was first added.
(This still does not matter just yet, but should do soon.)

diffstat:

 tests/bin/sh/t_syntax.sh |  23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diffs (53 lines):

diff -r 445054011ba7 -r b8d7c7737097 tests/bin/sh/t_syntax.sh
--- a/tests/bin/sh/t_syntax.sh  Sat Aug 19 21:13:11 2017 +0000
+++ b/tests/bin/sh/t_syntax.sh  Sat Aug 19 21:18:47 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_syntax.sh,v 1.7 2017/08/18 21:22:30 kre Exp $
+# $NetBSD: t_syntax.sh,v 1.8 2017/08/19 21:18:47 kre Exp $
 #
 # Copyright (c) 2017 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -300,8 +300,8 @@
        atf_set "descr" "Check processing of $' ' quoting (C style strings)"
 }
 d_cstrings_body() {
-       set -xv
        unset ENV
+
        if ! ${TEST_SH} -c ": \$'abc'" ||
             test $( ${TEST_SH} -c "printf %s \$'abc'" ) != abc
        then
@@ -335,7 +335,6 @@
        # all the \X sequences for a single char X (ie: not hex/octal/unicode)
        atf_check -s exit:0 -e empty -o inline:'\n\r\t\n' \
                ${TEST_SH} -c "printf '%s\\n' \$'\\a\\b\\e\\f\\n\\r\\t\\v'"
-#      atf_check -s exit:0 -e empty -o inline:'\7\10\33\14\12\15\11\13' \
        atf_check -s exit:0 -e empty -o inline:'\n\r\t\n' \
           ${TEST_SH} -c "printf '%s\\n' \$'\\cG\\cH\\x1b\\cl\\cJ\\cm\\cI\\ck'"
        atf_check -s exit:0 -e empty -o inline:"'"'"\\\n' \
@@ -363,8 +362,24 @@
 
        # \newline in a $'...' is dropped (just like in "" strings)
        atf_check -s exit:0 -e empty -o inline:'abcdef' ${TEST_SH} -c \
-               "printf '%s' \$'abc\\
+"printf '%s' \$'abc\\
+def'"
+       # but a normal newline in a $'...' is just a newline
+       atf_check -s exit:0 -e empty -o inline:'abc\ndef' ${TEST_SH} -c \
+"printf '%s' \$'abc
 def'"
+       # and should work when elided line wrap occurs between $ and '
+       atf_check -s exit:0 -e empty -o inline:'abc\ndef' ${TEST_SH} -c \
+"printf '%s' \$\\
+'abc\\ndef'"
+
+       # $'...' only works when the $ is unquoted.
+       atf_check -s exit:0 -e empty -o inline:"abc\$'def'g" ${TEST_SH} -c \
+               "printf '%s' \"abc\$'def'g\""
+       atf_check -s exit:0 -e empty -o inline:'abc$defg' ${TEST_SH} -c \
+               "printf '%s' abc\\\$'def'g"
+       atf_check -s exit:0 -e empty -o inline:'abc$def' ${TEST_SH} -c \
+               "printf '%s' abc'\$'def"
 }
 
 atf_test_case f_redirects



Home | Main Index | Thread Index | Old Index