aboutsummaryrefslogtreecommitdiff
path: root/unit-tests/test/script
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-11-25 11:19:40 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-25 11:19:40 +0200
commita3dad2118fb3925ef4f9baa90cea0dfd44ca93c6 (patch)
tree54748b5d85cab7bfb70a7baf66fe902c82cf3d66 /unit-tests/test/script
parent28f8338ded34f160e0083da9be4679bc778be7ca (diff)
Allow here-document end marker to be wholly quoted
Diffstat (limited to 'unit-tests/test/script')
-rw-r--r--unit-tests/test/script/lexer/buildfile2
-rw-r--r--unit-tests/test/script/parser/command-re-parse.test2
-rw-r--r--unit-tests/test/script/parser/here-document.test87
-rw-r--r--unit-tests/test/script/parser/here-string.test4
-rw-r--r--unit-tests/test/script/parser/redirect.test2
5 files changed, 87 insertions, 10 deletions
diff --git a/unit-tests/test/script/lexer/buildfile b/unit-tests/test/script/lexer/buildfile
index 16be005..ac833e4 100644
--- a/unit-tests/test/script/lexer/buildfile
+++ b/unit-tests/test/script/lexer/buildfile
@@ -10,6 +10,6 @@ test/script/{token lexer}
exe{driver}: cxx{driver} ../../../../build2/cxx{$src} $libs \
test{script-line command-line first-token second-token variable-line \
- description-line variable comment}
+ description-line variable}
include ../../../../build2/
diff --git a/unit-tests/test/script/parser/command-re-parse.test b/unit-tests/test/script/parser/command-re-parse.test
index 3b9ae3e..aee4f78 100644
--- a/unit-tests/test/script/parser/command-re-parse.test
+++ b/unit-tests/test/script/parser/command-re-parse.test
@@ -5,5 +5,5 @@ $* <<EOI >>EOO
x = cmd \\">-\\" "'<-'"
\$x
EOI
-cmd ">-" "<-"
+cmd '>-' '<-'
EOO
diff --git a/unit-tests/test/script/parser/here-document.test b/unit-tests/test/script/parser/here-document.test
index 4fa62d2..6f26166 100644
--- a/unit-tests/test/script/parser/here-document.test
+++ b/unit-tests/test/script/parser/here-document.test
@@ -1,3 +1,78 @@
+: end-marker
+:
+{
+ : missing-newline
+ :
+ $* <'cmd <<' 2>>EOE != 0
+ testscript:1:7: error: expected here-document end marker
+ EOE
+
+ : missing-exit
+ :
+ $* <'cmd << != 0' 2>>EOE != 0
+ testscript:1:8: error: expected here-document end marker
+ EOE
+
+ : unseparated-expansion
+ :
+ $* <'cmd <<FOO$foo' 2>>EOE != 0
+ testscript:1:10: error: here-document end marker must be literal
+ EOE
+
+ : quoted-single-partial
+ :
+ $* <"cmd <<F'O'O" 2>>EOE != 0
+ testscript:1:7: error: partially-quoted here-document end marker
+ EOE
+
+ : quoted-double-partial
+ :
+ $* <'cmd <<"FO"O' 2>>EOE != 0
+ testscript:1:7: error: partially-quoted here-document end marker
+ EOE
+
+ : quoted-mixed
+ :
+ $* <"cmd <<\"FO\"'O'" 2>>EOE != 0
+ testscript:1:7: error: partially-quoted here-document end marker
+ EOE
+
+ : unseparated
+ :
+ $* <<EOI >>EOO
+ cmd <<EOF!=0
+ foo
+ EOF
+ EOI
+ cmd <<EOF != 0
+ foo
+ EOF
+ EOO
+
+ : quoted-single
+ :
+ $* <<EOI >>EOO
+ cmd <<'EOF'
+ foo
+ EOF
+ EOI
+ cmd <<EOF
+ foo
+ EOF
+ EOO
+
+ : quoted-double
+ :
+ $* <<EOI >>EOO
+ cmd <<"EOF"
+ foo
+ EOF
+ EOI
+ cmd <<EOF
+ foo
+ EOF
+ EOO
+}
: indent
:
@@ -87,7 +162,9 @@
EOE
}
-$* <<EOI >>EOO # blank-lines
+: blank
+:
+$* <<EOI >>EOO
cmd <<EOF
foo
@@ -103,10 +180,10 @@ bar
EOF
EOO
-# quote
-#
-# Note: they are still recognized in eval contexts.
-#
+: quote
+:
+: Note: they are still recognized in eval contexts.
+:
$* <<EOI >>EOO
cmd <<EOF
'single'
diff --git a/unit-tests/test/script/parser/here-string.test b/unit-tests/test/script/parser/here-string.test
index 9f44bb2..9c4b68b 100644
--- a/unit-tests/test/script/parser/here-string.test
+++ b/unit-tests/test/script/parser/here-string.test
@@ -1,11 +1,11 @@
$* <<EOI >>EOO # empty
cmd <""
EOI
-cmd <""
+cmd <''
EOO
$* <<EOI >>EOO # empty-nn
cmd <:""
EOI
-cmd <:""
+cmd <:''
EOO
diff --git a/unit-tests/test/script/parser/redirect.test b/unit-tests/test/script/parser/redirect.test
index af4295a..2642834 100644
--- a/unit-tests/test/script/parser/redirect.test
+++ b/unit-tests/test/script/parser/redirect.test
@@ -11,7 +11,7 @@ EOO
$* <<EOI >>EOO # quote-file
cmd 0<<<"a f" 1>>>"b f" 2>>>&"c f"
EOI
-cmd <<<"a f" >>>"b f" 2>>>&"c f"
+cmd <<<'a f' >>>'b f' 2>>>&'c f'
EOO
$* <<EOI 2>>EOE !=0 # in-file-fail1