Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/bin/sh Added tests collected by Sven Mascheck
details: https://anonhg.NetBSD.org/src/rev/c8f0fc0cd0de
branches: trunk
changeset: 344467:c8f0fc0cd0de
user: christos <christos%NetBSD.org@localhost>
date: Thu Mar 31 16:20:39 2016 +0000
description:
Added tests collected by Sven Mascheck
http://www.in-ulm.de/~mascheck/various/cmd-subst/
which test cases of ')' being embedded in command substitutions.
(from kre@)
diffstat:
tests/bin/sh/t_cmdsub.sh | 113 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 112 insertions(+), 1 deletions(-)
diffs (133 lines):
diff -r 8d14b10c09b3 -r c8f0fc0cd0de tests/bin/sh/t_cmdsub.sh
--- a/tests/bin/sh/t_cmdsub.sh Thu Mar 31 16:19:52 2016 +0000
+++ b/tests/bin/sh/t_cmdsub.sh Thu Mar 31 16:20:39 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_cmdsub.sh,v 1.2 2016/03/27 14:53:17 christos Exp $
+# $NetBSD: t_cmdsub.sh,v 1.3 2016/03/31 16:20:39 christos Exp $
#
# Copyright (c) 2016 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -519,6 +519,116 @@
EOF'
}
+atf_test_case v_cmdsub_paren_tests
+v_cmdsub__paren_tests_head() {
+ atf_set "descr" "tests with cmdsubs containing embedded ')'"
+}
+v_cmdsub_paren_tests_body() {
+
+ # Tests from:
+ # http://www.in-ulm.de/~mascheck/various/cmd-subst/
+ # (slightly modified.)
+
+ atf_check -s exit:0 -o inline:'A.1\n' -e empty ${TEST_SH} -c \
+ 'echo $(
+ case x in x) echo A.1;; esac
+ )'
+
+ atf_check -s exit:0 -o inline:'A.2\n' -e empty ${TEST_SH} -c \
+ 'echo $(
+ case x in x) echo A.2;; esac # comment
+ )'
+
+ atf_check -s exit:0 -o inline:'A.3\n' -e empty ${TEST_SH} -c \
+ 'echo $(
+ case x in (x) echo A.3;; esac
+ )'
+
+ atf_check -s exit:0 -o inline:'A.4\n' -e empty ${TEST_SH} -c \
+ 'echo $(
+ case x in (x) echo A.4;; esac # comment
+ )'
+
+ atf_check -s exit:0 -o inline:'A.5\n' -e empty ${TEST_SH} -c \
+ 'echo $(
+ case x in (x) echo A.5
+ esac
+ )'
+
+ atf_check -s exit:0 -o inline:'B: quoted )\n' -e empty ${TEST_SH} -c \
+ 'echo $(
+ echo '\''B: quoted )'\''
+ )'
+
+ atf_check -s exit:0 -o inline:'C: comment then closing paren\n' \
+ -e empty ${TEST_SH} -c \
+ 'echo $(
+ echo C: comment then closing paren # )
+ )'
+
+ atf_check -s exit:0 -o inline:'D.1: here-doc with )\n' \
+ -e empty ${TEST_SH} -c \
+ 'echo $(
+ cat <<-\eof
+ D.1: here-doc with )
+ eof
+ )'
+
+ # D.2 is a bogus test.
+
+ atf_check -s exit:0 -o inline:'D.3: here-doc with \()\n' \
+ -e empty ${TEST_SH} -c \
+ 'echo $(
+ cat <<-\eof
+ D.3: here-doc with \()
+ eof
+ )'
+
+ atf_check -s exit:0 -e empty \
+ -o inline:'E: here-doc terminated with a parenthesis ("academic")\n' \
+ ${TEST_SH} -c \
+ 'echo $(
+ cat <<-\)
+ E: here-doc terminated with a parenthesis ("academic")
+ )
+ )'
+
+ atf_check -s exit:0 -e empty \
+-o inline:'F.1: here-doc embed with unbal single, back- or doublequote '\''\n' \
+ ${TEST_SH} -c \
+ 'echo $(
+ cat <<-"eof"
+ F.1: here-doc embed with unbal single, back- or doublequote '\''
+ eof
+ )'
+ atf_check -s exit:0 -e empty \
+ -o inline:'F.2: here-doc embed with unbal single, back- or doublequote "\n' \
+ ${TEST_SH} -c \
+ 'echo $(
+ cat <<-"eof"
+ F.2: here-doc embed with unbal single, back- or doublequote "
+ eof
+ )'
+ atf_check -s exit:0 -e empty \
+ -o inline:'F.3: here-doc embed with unbal single, back- or doublequote `\n' \
+ ${TEST_SH} -c \
+ 'echo $(
+ cat <<-"eof"
+ F.3: here-doc embed with unbal single, back- or doublequote `
+ eof
+ )'
+
+ atf_check -s exit:0 -e empty -o inline:'G: backslash at end of line\n' \
+ ${TEST_SH} -c \
+ 'echo $(
+ echo G: backslash at end of line # \
+ )'
+
+ atf_check -s exit:0 -e empty \
+ -o inline:'H: empty command-substitution\n' \
+ ${TEST_SH} -c 'echo H: empty command-substitution $( )'
+}
+
atf_test_case z_absurd_heredoc_cmdsub_combos
z_absurd_heredoc_cmdsub_combos_head() {
atf_set "descr" "perverse and unusual cmd substitutions & more"
@@ -590,5 +700,6 @@
atf_add_test_case s_heredoc_in_backticks
atf_add_test_case t_nested_cmdsubs_in_heredoc
atf_add_test_case u_nested_backticks_in_heredoc
+ atf_add_test_case v_cmdsub_paren_tests
atf_add_test_case z_absurd_heredoc_cmdsub_combos
}
Home |
Main Index |
Thread Index |
Old Index