From c5690658b810844366e5508cdaeb5dc299060c43 Mon Sep 17 00:00:00 2001 From: WATANABE Yuki Date: Fri, 13 Dec 2024 01:24:24 +0900 Subject: [PATCH] Sync tests for quotation with yash This commit imports updates to the tests for quotation from: https://github.com/magicant/yash/commit/b10320c539c42aaa32f9aa1baef987c3c8973c14 --- yash-cli/tests/scripted_test/quote-p.sh | 85 ++++++++++++++++++++----- yash-cli/tests/scripted_test/quote-y.sh | 81 ----------------------- 2 files changed, 69 insertions(+), 97 deletions(-) diff --git a/yash-cli/tests/scripted_test/quote-p.sh b/yash-cli/tests/scripted_test/quote-p.sh index e749b777..3d6c5406 100644 --- a/yash-cli/tests/scripted_test/quote-p.sh +++ b/yash-cli/tests/scripted_test/quote-p.sh @@ -487,18 +487,17 @@ __IN__ [abcdefghijklmnopqrstuvwxyz{|}~][``] __OUT__ -# \{ and \} are tested in quote-y.tst. test_oE 'backslashes in substitution of expansion ${a+b} in double quotes' a=a bracket "${a+\ \!\$x\%\&\(\)\*\+\,\-\.\/ \# \"x\" \'x\'}" bracket "${a+\0\1\2\3\4\5\6\7\8\9\:\;\<\=\>\? \\ \\\\}" bracket "${a+\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z\[\]\^\_}" -bracket "${a+\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z\|\~ \`\`}" +bracket "${a+\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z\{\|\}\~ \`\`}" __IN__ [\ \!$x\%\&\(\)\*\+\,\-\.\/ \# "x" \'x\'] [\0\1\2\3\4\5\6\7\8\9\:\;\<\=\>\? \ \\] [\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z\[\]\^\_] -[\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z\|\~ ``] +[\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z\{\|}\~ ``] __OUT__ test_oE 'backslashes in substitution of expansion ${a-b}' @@ -513,25 +512,72 @@ __IN__ [abcdefghijklmnopqrstuvwxyz{|}~][``] __OUT__ -# \{ and \} are tested in quote-y.tst. test_oE 'backslashes in substitution of expansion ${a-b} in double quotes' bracket "${u-\ \!\$x\%\&\(\)\*\+\,\-\.\/ \# \"x\" \'x\'}" bracket "${u-\0\1\2\3\4\5\6\7\8\9\:\;\<\=\>\? \\ \\\\}" bracket "${u-\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z\[\]\^\_}" -bracket "${u-\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z\|\~ \`\`}" +bracket "${u-\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z\{\|\}\~ \`\`}" __IN__ [\ \!$x\%\&\(\)\*\+\,\-\.\/ \# "x" \'x\'] [\0\1\2\3\4\5\6\7\8\9\:\;\<\=\>\? \ \\] [\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z\[\]\^\_] -[\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z\|\~ ``] +[\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z\{\|}\~ ``] +__OUT__ + +# Quote removal is performed before assignment, so the resultant expansions are +# subject to field splitting. +# TODO The first expected line should not contain a space. +test_oE 'quotes in substitution of expansion ${a=b}' +bracket ${a=\ \!\$x\%\&\(\)\*\+\,\-\.\/ \# \"x\" \'x\'} +bracket ${b=\0\1\2\3\4\5\6\7\8\9\:\;\<\=\>\? \\ \\\\} +bracket ${c=\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z\[\]\^\_} +bracket ${d=\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z\{\|\}\~ \`\`} +bracket $a +bracket $b +bracket $c +bracket $d +__IN__ +[ !$x%&()*+,-./][#]["x"]['x'] +[0123456789:;<=>?][\][\\] +[@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_] +[abcdefghijklmnopqrstuvwxyz{|}~][``] +[!$x%&()*+,-./][#]["x"]['x'] +[0123456789:;<=>?][\][\\] +[@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_] +[abcdefghijklmnopqrstuvwxyz{|}~][``] __OUT__ -# See quote-y.tst -#test_oE 'backslashes in substitution of expansion ${a=b}' -#__IN__ -#__OUT__ +# Quote removal is performed before assignment, but the resultant expansions +# are not subject to field splitting because they are double-quoted. +test_oE 'quotes in substitution of expansion ${a=b} in double quotes' +bracket "${a=\ \!\$x\%\&\(\)\*\+\,\-\.\/ \# \"x\" \'x\'}" +bracket "${b=\0\1\2\3\4\5\6\7\8\9\:\;\<\=\>\? \\ \\\\}" +bracket "${c=\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z\[\]\^\_}" +bracket "${d=\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z\{\|\}\~ \`\`}" +bracket "${e=a"b"c}" "${f=a"*"c}" "${g=a"\"\""c}" "${h=a"\\"c}" "${i=a"''"c}" +bracket "${j=a'b'c}" "${k=a'*'c}" "${l=a'""'c}" "${m=a'\'c}" +bracket "$a" +bracket "$b" +bracket "$c" +bracket "$d" +bracket "$e" "$f" "$g" "$h" "$i" +bracket "$j" "$k" "$l" "$m" +__IN__ +[\ \!$x\%\&\(\)\*\+\,\-\.\/ \# "x" \'x\'] +[\0\1\2\3\4\5\6\7\8\9\:\;\<\=\>\? \ \\] +[\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z\[\]\^\_] +[\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z\{\|}\~ ``] +[abc][a*c][a""c][a\c][a''c] +[a'b'c][a'*'c][a''c][a'\'c] +[\ \!$x\%\&\(\)\*\+\,\-\.\/ \# "x" \'x\'] +[\0\1\2\3\4\5\6\7\8\9\:\;\<\=\>\? \ \\] +[\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z\[\]\^\_] +[\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z\{\|}\~ ``] +[abc][a*c][a""c][a\c][a''c] +[a'b'c][a'*'c][a''c][a'\'c] +__OUT__ -# See quote-y.tst +# Not tested since the error message format depends on implementations. #test_oE 'backslashes in substitution of expansion ${a?b}' #__IN__ #__OUT__ @@ -553,12 +599,19 @@ __IN__ [abc][a*c][a""c][a\c] __OUT__ -# See quote-y.tst -#test_oE 'single and double quotes in substitution of expansion ${a=b}' -#__IN__ -#__OUT__ +test_oE 'single and double quotes in substitution of expansion ${a=b}' +bracket ${a=a"b"c} ${b=a"*"c} ${c=a"\"\""c} ${d=a"\\"c} ${e=a"''"c} +bracket ${f=a'b'c} ${g=a'*'c} ${h=a'""'c} ${i=a'\'c} +bracket $a $b $c $d $e +bracket $f $g $h $i +__IN__ +[abc][a*c][a""c][a\c][a''c] +[abc][a*c][a""c][a\c] +[abc][a*c][a""c][a\c][a''c] +[abc][a*c][a""c][a\c] +__OUT__ -# See quote-y.tst +# Not tested since the error message format depends on implementations. #test_oE 'single and double quotes in substitution of expansion ${a?b}' #__IN__ #__OUT__ diff --git a/yash-cli/tests/scripted_test/quote-y.sh b/yash-cli/tests/scripted_test/quote-y.sh index 3dc085d9..d743bc08 100644 --- a/yash-cli/tests/scripted_test/quote-y.sh +++ b/yash-cli/tests/scripted_test/quote-y.sh @@ -1,86 +1,5 @@ # quote-y.sh: yash-specific test of quoting -( -setup -d - -posix="true" - -# POSIX does not imply that quote removal should be applied before the expanded -# word is assigned to the unset/empty variable. However, existing shells seem -# to perform quote removal, so yash follows them. Also note that the resultant -# value of the parameter expansion has quote removal already applied, so it is -# subject to field splitting. -# TODO The first expected line should not contain a space -test_oE 'quotes in substitution of expansion ${a=b}' -bracket ${a=\ \!\$x\%\&\(\)\*\+\,\-\.\/ \# \"x\" \'x\'} -bracket ${b=\0\1\2\3\4\5\6\7\8\9\:\;\<\=\>\? \\ \\\\} -bracket ${c=\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z\[\]\^\_} -bracket ${d=\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z\{\|\}\~ \`\`} -bracket ${e=a"b"c} ${f=a"*"c} ${g=a"\"\""c} ${h=a"\\"c} ${i=a"''"c} -bracket ${j=a'b'c} ${k=a'*'c} ${l=a'""'c} ${m=a'\'c} -bracket $a -bracket $b -bracket $c -bracket $d -bracket $e $f $g $h $i -bracket $j $k $l $m -__IN__ -[ !$x%&()*+,-./][#]["x"]['x'] -[0123456789:;<=>?][\][\\] -[@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_] -[abcdefghijklmnopqrstuvwxyz{|}~][``] -[abc][a*c][a""c][a\c][a''c] -[abc][a*c][a""c][a\c] -[!$x%&()*+,-./][#]["x"]['x'] -[0123456789:;<=>?][\][\\] -[@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_] -[abcdefghijklmnopqrstuvwxyz{|}~][``] -[abc][a*c][a""c][a\c][a''c] -[abc][a*c][a""c][a\c] -__OUT__ - -# \{ and \} are tested below -test_oE 'quotes in substitution of expansion ${a=b} in double quotes' -bracket "${a=\ \!\$x\%\&\(\)\*\+\,\-\.\/ \# \"x\" \'x\'}" -bracket "${b=\0\1\2\3\4\5\6\7\8\9\:\;\<\=\>\? \\ \\\\}" -bracket "${c=\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z\[\]\^\_}" -bracket "${d=\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z\|\~ \`\`}" -bracket "${e=a"b"c}" "${f=a"*"c}" "${g=a"\"\""c}" "${h=a"\\"c}" "${i=a"''"c}" -bracket "${j=a'b'c}" "${k=a'*'c}" "${l=a'""'c}" "${m=a'\'c}" -bracket "$a" -bracket "$b" -bracket "$c" -bracket "$d" -bracket "$e" "$f" "$g" "$h" "$i" -bracket "$j" "$k" "$l" "$m" -__IN__ -[\ \!$x\%\&\(\)\*\+\,\-\.\/ \# "x" \'x\'] -[\0\1\2\3\4\5\6\7\8\9\:\;\<\=\>\? \ \\] -[\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z\[\]\^\_] -[\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z\|\~ ``] -[abc][a*c][a""c][a\c][a''c] -[a'b'c][a'*'c][a''c][a'\'c] -[\ \!$x\%\&\(\)\*\+\,\-\.\/ \# "x" \'x\'] -[\0\1\2\3\4\5\6\7\8\9\:\;\<\=\>\? \ \\] -[\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z\[\]\^\_] -[\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z\|\~ ``] -[abc][a*c][a""c][a\c][a''c] -[a'b'c][a'*'c][a''c][a'\'c] -__OUT__ - -# TODO This should be moved to quote-p.sh -test_o -d -e 2 '\{ and \} in substitution of expansions in double quotes' -a=a -bracket "${a+1\{2\}3}" "${u-1\{2\}3}" "${b=1\{2\}3}" -bracket "$b" -eval '"${u?1\{2\}3}"' -__IN__ -[1\{2}3][1\{2}3][1\{2}3] -[1\{2}3] -__OUT__ - -) - test_oE 'null character in dollar-single-quotes' printf '%s\n' a$'b\0c'd w$'x\x0y'z 1$'2\c@3'4 __IN__