Add a new test case wrap_strip based upon strip (ie: cut&paste.. to start)
but with \ newline line continuations inserted at strange places. For the shell as it is today, since strip passes, wrap_strip should automaticallty pass as well (and does), as the \ newline combination is simply removed, producing identical input to that of strip. However, for accurate line counting ($LINENO: coming soon) newlines (no matter the context) cannot simply "go away" - we have to know where they occur(ed) (perhaps long after the text was read) so we know what line number we are actually processing. This new test case is (perhaps just part) of future-proofing that the modified code does not break anything.
This commit is contained in:
parent
374c12e6d0
commit
6768e34b73
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: t_expand.sh,v 1.13 2017/05/15 19:53:40 kre Exp $
|
||||
# $NetBSD: t_expand.sh,v 1.14 2017/05/29 22:27:47 kre Exp $
|
||||
#
|
||||
# Copyright (c) 2007, 2009 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
|
@ -156,6 +156,50 @@ strip_body() {
|
|||
done
|
||||
}
|
||||
|
||||
atf_test_case wrap_strip
|
||||
wrap_strip_head() {
|
||||
atf_set "descr" "Checks that the %% operator works and strips" \
|
||||
"the contents of a variable from the given point" \
|
||||
'to the end, and that \ \n sequences do not break it'
|
||||
}
|
||||
wrap_strip_body() {
|
||||
line='#define bindir "/usr/bin" /* comment */'
|
||||
stripped='#define bindir "/usr/bin" '
|
||||
|
||||
for exp in \
|
||||
'${line\
|
||||
%%/\**}' \
|
||||
'${line%%"/\
|
||||
*"*}' \
|
||||
'${line%%'"'"'/*'"'"'\
|
||||
*}' \
|
||||
'"${li\
|
||||
ne%%/\**}"' \
|
||||
'"${line%%"\
|
||||
/*"*}"' \
|
||||
'"${line%\
|
||||
%'"'"'/*'"'"'*}"' \
|
||||
'${line\
|
||||
%\
|
||||
/\*\
|
||||
*\
|
||||
}' \
|
||||
'${line%"/*\
|
||||
"*\
|
||||
}' \
|
||||
'${line\
|
||||
%\
|
||||
'"'"'/*'"'"'*}' \
|
||||
'"$\
|
||||
{li\
|
||||
ne%\
|
||||
'"'"'/*'"'"'*}"'
|
||||
do
|
||||
atf_check -o inline:":$stripped:\n" -e empty ${TEST_SH} -c \
|
||||
"line='${line}'; echo :${exp}:"
|
||||
done
|
||||
}
|
||||
|
||||
atf_test_case varpattern_backslashes
|
||||
varpattern_backslashes_head() {
|
||||
atf_set "descr" "Tests that protecting wildcards with backslashes" \
|
||||
|
@ -896,6 +940,7 @@ atf_init_test_cases() {
|
|||
atf_add_test_case iteration_on_null_or_missing_parameter
|
||||
atf_add_test_case shell_params
|
||||
atf_add_test_case strip
|
||||
atf_add_test_case wrap_strip
|
||||
atf_add_test_case var_with_embedded_cmdsub
|
||||
atf_add_test_case varpattern_backslashes
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue