aboutsummaryrefslogtreecommitdiff
path: root/unit-tests/test/script/lexer
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-01-06 18:46:58 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-01-09 21:44:23 +0300
commitc55240fb05151cae046c75a793c164d72c988db2 (patch)
tree35cbba195e0fcc581944b7b098a3ea145741cf94 /unit-tests/test/script/lexer
parent9e2b4fd3bbc0c61bf6c84540c52869ec7d830718 (diff)
Tests cleanup (take 2)
Diffstat (limited to 'unit-tests/test/script/lexer')
-rw-r--r--unit-tests/test/script/lexer/command-expansion.test360
-rw-r--r--unit-tests/test/script/lexer/command-line.test311
-rw-r--r--unit-tests/test/script/lexer/description-line.test20
-rw-r--r--unit-tests/test/script/lexer/first-token.test52
-rw-r--r--unit-tests/test/script/lexer/second-token.test36
-rw-r--r--unit-tests/test/script/lexer/variable-line.test16
-rw-r--r--unit-tests/test/script/lexer/variable.test102
7 files changed, 573 insertions, 324 deletions
diff --git a/unit-tests/test/script/lexer/command-expansion.test b/unit-tests/test/script/lexer/command-expansion.test
index f113846..faae29d 100644
--- a/unit-tests/test/script/lexer/command-expansion.test
+++ b/unit-tests/test/script/lexer/command-expansion.test
@@ -1,134 +1,230 @@
+# file : unit-tests/test/script/lexer/command-expansion.test
+# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
test.arguments = command-expansion
-$* <:"0<+" >>EOO # in-pass-redirect
-'0'
-<+
-EOO
-
-$* <:"0 <+" >>EOO # arg-in-pass-redirect
-'0 '
-<+
-EOO
-
-$* <:"1>+" >>EOO # out-pass-redirect
-'1'
->+
-EOO
-
-$* <:"1 >+" >>EOO # arg-out-pass-redirect
-'1 '
->+
-EOO
-
-$* <:"0<-" >>EOO # in-null-redirect
-'0'
-<-
-EOO
-
-$* <:"0 <-" >>EOO # arg-in-null-redirect
-'0 '
-<-
-EOO
-
-$* <:"1>-" >>EOO # out-null-redirect
-'1'
->-
-EOO
-
-$* <:"1 >-" >>EOO # arg-out-null-redirect
-'1 '
->-
-EOO
-
-$* <:"1>&2" >>EOO # merge-redirect
-'1'
->&
-'2'
-EOO
-
-$* <:"1 >&2" >>EOO # arg-merge-redirect
-'1 '
->&
-'2'
-EOO
-
-$* <:"0<a b" >>EOO # in-str-redirect
-'0'
-<
-'a b'
-EOO
-
-$* <:"1>a b" >>EOO # out-str-redirect
-'1'
->
-'a b'
-EOO
-
-$* <:"0<:a b" >>EOO # in-str-nn-redirect
-'0'
-<:
-'a b'
-EOO
-
-$* <:"1>:a b" >>EOO # out-str-nn-redirect
-'1'
->:
-'a b'
-EOO
-
-$* <:"0<<E O I" >>EOO # in-doc-redirect
-'0'
-<<
-'E O I'
-EOO
-
-$* <:"1>>E O O" >>EOO # out-doc-redirect
-'1'
->>
-'E O O'
-EOO
-
-$* <:"0<<:E O I" >>EOO # in-doc-nn-redirect
-'0'
-<<:
-'E O I'
-EOO
-
-$* <:"1>>:E O O" >>EOO # out-doc-nn-redirect
-'1'
->>:
-'E O O'
-EOO
-
-$* <:"0<<<a b" >>EOO # in-file-redirect
-'0'
-<<<
-'a b'
-EOO
-
-$* <:"1>>>a b" >>EOO # out-file-redirect
-'1'
->>>
-'a b'
-EOO
-
-$* <:"1>>>&a b" >>EOO # out-file-app-redirect
-'1'
->>>&
-'a b'
-EOO
-
-$* <:"&file" >>EOO # cleanup-always
-&
-'file'
-EOO
-
-$* <:"&?file" >>EOO # cleanup-maybe
-&?
-'file'
-EOO
-
-$* <:"&!file" >>EOO # cleanup-never
-&!
-'file'
-EOO
+: pass-redirect
+:
+{
+ : in
+ :
+ $* <:"0<+" >>EOO
+ '0'
+ <+
+ EOO
+
+ : arg-in
+ :
+ $* <:"0 <+" >>EOO
+ '0 '
+ <+
+ EOO
+
+ : out
+ :
+ $* <:"1>+" >>EOO
+ '1'
+ >+
+ EOO
+
+ : arg-out
+ :
+ $* <:"1 >+" >>EOO
+ '1 '
+ >+
+ EOO
+}
+
+: null-redirect
+:
+{
+ : in
+ :
+ $* <:"0<-" >>EOO
+ '0'
+ <-
+ EOO
+
+ : arg-in
+ :
+ $* <:"0 <-" >>EOO
+ '0 '
+ <-
+ EOO
+
+ : out
+ :
+ $* <:"1>-" >>EOO
+ '1'
+ >-
+ EOO
+
+ : arg-out
+ :
+ $* <:"1 >-" >>EOO
+ '1 '
+ >-
+ EOO
+}
+
+: merge-redirect
+:
+{
+ : out
+ :
+ $* <:"1>&2" >>EOO
+ '1'
+ >&
+ '2'
+ EOO
+
+ : arg-out
+ :
+ $* <:"1 >&2" >>EOO
+ '1 '
+ >&
+ '2'
+ EOO
+}
+
+: str-redirect
+:
+{
+ : in
+ :
+ {
+ : newline
+ :
+ $* <:"0<a b" >>EOO
+ '0'
+ <
+ 'a b'
+ EOO
+
+ : no-newline
+ :
+ $* <:"0<:a b" >>EOO
+ '0'
+ <:
+ 'a b'
+ EOO
+ }
+
+ : out
+ :
+ {
+ : newline
+ :
+ $* <:"1>a b" >>EOO
+ '1'
+ >
+ 'a b'
+ EOO
+
+ : no-newline
+ :
+ $* <:"1>:a b" >>EOO
+ '1'
+ >:
+ 'a b'
+ EOO
+ }
+}
+
+: doc-redirect
+:
+{
+ : in
+ :
+ {
+ : newline
+ :
+ $* <:"0<<E O I" >>EOO
+ '0'
+ <<
+ 'E O I'
+ EOO
+
+ : no-newline
+ :
+ $* <:"0<<:E O I" >>EOO
+ '0'
+ <<:
+ 'E O I'
+ EOO
+ }
+
+ : out
+ :
+ {
+ : newline
+ :
+ $* <:"1>>E O O" >>EOO
+ '1'
+ >>
+ 'E O O'
+ EOO
+
+ : no-newline
+ :
+ $* <:"1>>:E O O" >>EOO
+ '1'
+ >>:
+ 'E O O'
+ EOO
+ }
+}
+
+: file-redirect
+:
+{
+ : in
+ :
+ $* <:"0<<<a b" >>EOO
+ '0'
+ <<<
+ 'a b'
+ EOO
+
+ : out
+ :
+ $* <:"1>>>a b" >>EOO
+ '1'
+ >>>
+ 'a b'
+ EOO
+
+ : out-app
+ :
+ $* <:"1>>>&a b" >>EOO
+ '1'
+ >>>&
+ 'a b'
+ EOO
+}
+
+: cleanup
+:
+{
+ : always
+ :
+ $* <:"&file" >>EOO
+ &
+ 'file'
+ EOO
+
+ : maybe
+ :
+ $* <:"&?file" >>EOO
+ &?
+ 'file'
+ EOO
+
+ : never
+ :
+ $* <:"&!file" >>EOO
+ &!
+ 'file'
+ EOO
+}
diff --git a/unit-tests/test/script/lexer/command-line.test b/unit-tests/test/script/lexer/command-line.test
index 0040cfe..8a73b3d 100644
--- a/unit-tests/test/script/lexer/command-line.test
+++ b/unit-tests/test/script/lexer/command-line.test
@@ -1,134 +1,187 @@
+# file : unit-tests/test/script/lexer/command-line.test
+# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
test.arguments = command-line
-$* <"cmd;" >>EOO # semi
-'cmd'
-;
-<newline>
-EOO
-
-$* <"cmd ;" >>EOO # semi-separated
-'cmd'
-;
-<newline>
-EOO
-
-$* <";" >>EOO # semi-only
-;
-<newline>
-EOO
-
-$* <"cmd: dsc" >>EOO # colon
-'cmd'
+: semi
+{
+ : immediate
+ :
+ $* <"cmd;" >>EOO
+ 'cmd'
+ ;
+ <newline>
+ EOO
+
+ : separated
+ :
+ $* <"cmd ;" >>EOO
+ 'cmd'
+ ;
+ <newline>
+ EOO
+
+ : only
+ :
+ $* <";" >>EOO
+ ;
+ <newline>
+ EOO
+}
+
+: colon
:
-'dsc'
-<newline>
-EOO
-
-$* <"cmd :dsc" >>EOO # colon-separated
-'cmd'
+{
+ : immediate
+ :
+ $* <"cmd: dsc" >>EOO
+ 'cmd'
+ :
+ 'dsc'
+ <newline>
+ EOO
+
+ : separated
+ :
+ $* <"cmd :dsc" >>EOO
+ 'cmd'
+ :
+ 'dsc'
+ <newline>
+ EOO
+
+ : only
+ :
+ $* <":" >>EOO
+ :
+ <newline>
+ EOO
+}
+
+: redirect
:
-'dsc'
-<newline>
-EOO
-
-$* <":" >>EOO # colon-only
+{
+ : pass
+ :
+ $* <"cmd <+ 1>+" >>EOO
+ 'cmd'
+ <+
+ '1'
+ >+
+ <newline>
+ EOO
+
+ : null
+ :
+ $* <"cmd <- 1>-" >>EOO
+ 'cmd'
+ <-
+ '1'
+ >-
+ <newline>
+ EOO
+
+ : merge
+ :
+ $* <"cmd 1>&2" >>EOO
+ 'cmd'
+ '1'
+ >&
+ '2'
+ <newline>
+ EOO
+
+ : str
+ :
+ $* <"cmd <a 1>b" >>EOO
+ 'cmd'
+ <
+ 'a'
+ '1'
+ >
+ 'b'
+ <newline>
+ EOO
+
+ : str-nn
+ :
+ $* <"cmd <:a 1>:b" >>EOO
+ 'cmd'
+ <:
+ 'a'
+ '1'
+ >:
+ 'b'
+ <newline>
+ EOO
+
+ : doc
+ :
+ $* <"cmd <<EOI 1>>EOO" >>EOO
+ 'cmd'
+ <<
+ 'EOI'
+ '1'
+ >>
+ 'EOO'
+ <newline>
+ EOO
+
+ : doc-nn
+ :
+ $* <"cmd <<:EOI 1>>:EOO" >>EOO
+ 'cmd'
+ <<:
+ 'EOI'
+ '1'
+ >>:
+ 'EOO'
+ <newline>
+ EOO
+
+ : file
+ :
+ $* <"cmd <<<in >>>out 2>>>&err" >>EOO
+ 'cmd'
+ <<<
+ 'in'
+ >>>
+ 'out'
+ '2'
+ >>>&
+ 'err'
+ <newline>
+ EOO
+}
+
+: cleanup
:
-<newline>
-EOO
-
-$* <"cmd <+ 1>+" >>EOO # pass-redirect
-'cmd'
-<+
-'1'
->+
-<newline>
-EOO
-
-$* <"cmd <- 1>-" >>EOO # null-redirect
-'cmd'
-<-
-'1'
->-
-<newline>
-EOO
-
-$* <"cmd 1>&2" >>EOO # merge-redirect
-'cmd'
-'1'
->&
-'2'
-<newline>
-EOO
-
-$* <"cmd <a 1>b" >>EOO # str-redirect
-'cmd'
-<
-'a'
-'1'
->
-'b'
-<newline>
-EOO
-
-$* <"cmd <:a 1>:b" >>EOO # str-nn-redirect
-'cmd'
-<:
-'a'
-'1'
->:
-'b'
-<newline>
-EOO
-
-$* <"cmd <<EOI 1>>EOO" >>EOO # doc-redirect
-'cmd'
-<<
-'EOI'
-'1'
->>
-'EOO'
-<newline>
-EOO
-
-$* <"cmd <<:EOI 1>>:EOO" >>EOO # doc-nn-redirect
-'cmd'
-<<:
-'EOI'
-'1'
->>:
-'EOO'
-<newline>
-EOO
-
-$* <"cmd <<<in >>>out 2>>>&err" >>EOO # file-redirect
-'cmd'
-<<<
-'in'
->>>
-'out'
-'2'
->>>&
-'err'
-<newline>
-EOO
-
-$* <"cmd &file" >>EOO # cleanup-always
-'cmd'
-&
-'file'
-<newline>
-EOO
-
-$* <"cmd &?file" >>EOO # cleanup-maybe
-'cmd'
-&?
-'file'
-<newline>
-EOO
-
-$* <"cmd &!file" >>EOO # cleanup-never
-'cmd'
-&!
-'file'
-<newline>
-EOO
+{
+ : always
+ :
+ $* <"cmd &file" >>EOO
+ 'cmd'
+ &
+ 'file'
+ <newline>
+ EOO
+
+ : maybe
+ :
+ $* <"cmd &?file" >>EOO
+ 'cmd'
+ &?
+ 'file'
+ <newline>
+ EOO
+
+ : never
+ :
+ $* <"cmd &!file" >>EOO
+ 'cmd'
+ &!
+ 'file'
+ <newline>
+ EOO
+}
diff --git a/unit-tests/test/script/lexer/description-line.test b/unit-tests/test/script/lexer/description-line.test
index 0f70e77..6b160c0 100644
--- a/unit-tests/test/script/lexer/description-line.test
+++ b/unit-tests/test/script/lexer/description-line.test
@@ -1,20 +1,32 @@
+# file : unit-tests/test/script/lexer/description-line.test
+# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
test.arguments = description-line
-$* <" foo bar " >>EOO # full
+: full
+:
+$* <" foo bar " >>EOO
' foo bar '
<newline>
EOO
-$* <" " >>EOO # space
+: space
+:
+$* <" " >>EOO
' '
<newline>
EOO
-$* <"" >>EOO # empty
+: empty
+:
+$* <"" >>EOO
<newline>
EOO
-$* <:"foo" >>EOO 2>>EOE != 0 # eof
+: eof
+:
+$* <:"foo" >>EOO 2>>EOE != 0
'foo'
EOO
stdin:1:4: error: expected newline at the end of description line
diff --git a/unit-tests/test/script/lexer/first-token.test b/unit-tests/test/script/lexer/first-token.test
index 8a6d39b..6044f53 100644
--- a/unit-tests/test/script/lexer/first-token.test
+++ b/unit-tests/test/script/lexer/first-token.test
@@ -1,68 +1,96 @@
+# file : unit-tests/test/script/lexer/first-token.test
+# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
# Note: this mode auto-expires after each token.
#
test.arguments = first-token
-$* <"." >>EOO # dot
+: dot
+:
+$* <"." >>EOO
.
<newline>
EOO
-$* <";" >>EOO # semi
+: semi
+:
+$* <";" >>EOO
;
<newline>
EOO
-$* <":" >>EOO # colon
+: colon
+:
+$* <":" >>EOO
:
<newline>
EOO
-$* <"{" >>EOO # lcbrace
+: lcbrace
+:
+$* <"{" >>EOO
{
<newline>
EOO
-$* <"}" >>EOO # rcbrace
+: rcbrace
+:
+$* <"}" >>EOO
}
<newline>
EOO
-$* <"+foo" >>EOO # setup
+: setup
+:
+$* <"+foo" >>EOO
+
'foo'
<newline>
EOO
-$* <"- foo" >>EOO # tdown
+: tdown
+:
+$* <"- foo" >>EOO
-
'foo'
<newline>
EOO
-$* <"foo+bar" >>EOO # plus-leading
+: plus-leading
+:
+$* <"foo+bar" >>EOO
'foo+bar'
<newline>
EOO
-$* <"foo- x" >>EOO # minus-leading
+: minus-leading
+:
+$* <"foo- x" >>EOO
'foo-'
'x'
<newline>
EOO
-$* <"foo=" >>EOO # assign
+: assign
+:
+$* <"foo=" >>EOO
'foo'
'='
<newline>
EOO
-$* <"foo+=" >>EOO # append
+: append
+:
+$* <"foo+=" >>EOO
'foo'
'+='
<newline>
EOO
-$* <"foo=+" >>EOO # prepend
+: prepend
+:
+$* <"foo=+" >>EOO
'foo'
'=+'
<newline>
diff --git a/unit-tests/test/script/lexer/second-token.test b/unit-tests/test/script/lexer/second-token.test
index 94cdf95..94ea441 100644
--- a/unit-tests/test/script/lexer/second-token.test
+++ b/unit-tests/test/script/lexer/second-token.test
@@ -1,47 +1,67 @@
+# file : unit-tests/test/script/lexer/second-token.test
+# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
# Note: this mode auto-expires after each token.
#
test.arguments = second-token
-$* <";" >>EOO # semi
+: semi
+:
+$* <";" >>EOO
;
<newline>
EOO
-$* <":" >>EOO # colon
+: colon
+:
+$* <":" >>EOO
:
<newline>
EOO
-$* <"=foo" >>EOO # assign
+: assign
+:
+$* <"=foo" >>EOO
=
'foo'
<newline>
EOO
-$* <"+= foo" >>EOO # append
+: append
+:
+$* <"+= foo" >>EOO
+=
'foo'
<newline>
EOO
-$* <" =+ foo" >>EOO # prepend
+: prepend
+:
+$* <" =+ foo" >>EOO
=+
'foo'
<newline>
EOO
-$* <"foo=bar" >>EOO # assign-leading
+: assign-leading
+:
+$* <"foo=bar" >>EOO
'foo=bar'
<newline>
EOO
-$* <"foo+= bar" >>EOO # append-leading
+: append-leading
+:
+$* <"foo+= bar" >>EOO
'foo+='
'bar'
<newline>
EOO
-$* <"foo =+bar" >>EOO # prepend-leading
+: prepend-leading
+:
+$* <"foo =+bar" >>EOO
'foo'
'=+bar'
<newline>
diff --git a/unit-tests/test/script/lexer/variable-line.test b/unit-tests/test/script/lexer/variable-line.test
index 126fe54..c97981d 100644
--- a/unit-tests/test/script/lexer/variable-line.test
+++ b/unit-tests/test/script/lexer/variable-line.test
@@ -1,18 +1,28 @@
+# file : unit-tests/test/script/lexer/variable-line.test
+# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
test.arguments = variable-line
-$* <"cmd;" >>EOO # semi
+: semi
+:
+$* <"cmd;" >>EOO
'cmd'
;
<newline>
EOO
-$* <"cmd ;" >>EOO # semi-separated
+: semi-separated
+:
+$* <"cmd ;" >>EOO
'cmd'
;
<newline>
EOO
-$* <";" >>EOO # semi-only
+: semi-only
+:
+$* <";" >>EOO
;
<newline>
EOO
diff --git a/unit-tests/test/script/lexer/variable.test b/unit-tests/test/script/lexer/variable.test
index 0ecc6cc..15458f5 100644
--- a/unit-tests/test/script/lexer/variable.test
+++ b/unit-tests/test/script/lexer/variable.test
@@ -1,40 +1,70 @@
+# file : unit-tests/test/script/lexer/variable.test
+# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
# Test handling custom variable names ($*, $~, $NN).
#
test.arguments = variable
-$* <"*" >>EOO
-'*'
-<newline>
-EOO
-
-$* <"*abc" >>EOO
-'*'
-'abc'
-<newline>
-EOO
-
-$* <"~" >>EOO
-'~'
-<newline>
-EOO
-
-$* <"~123" >>EOO
-'~'
-'123'
-<newline>
-EOO
-
-$* <"0" >>EOO
-'0'
-<newline>
-EOO
-
-$* <"1abc" >>EOO
-'1'
-'abc'
-<newline>
-EOO
-
-$* <"10" 2>>EOE != 0
-stdin:1:1: error: multi-digit special variable name
-EOE
+: command
+:
+{
+ : only
+ :
+ $* <"*" >>EOO
+ '*'
+ <newline>
+ EOO
+
+ : followed
+ :
+ $* <"*abc" >>EOO
+ '*'
+ 'abc'
+ <newline>
+ EOO
+}
+
+: working-dir
+:
+{
+ : only
+ :
+ $* <"~" >>EOO
+ '~'
+ <newline>
+ EOO
+
+ : followed
+ :
+ $* <"~123" >>EOO
+ '~'
+ '123'
+ <newline>
+ EOO
+}
+
+: arg
+:
+{
+ : only
+ :
+ $* <"0" >>EOO
+ '0'
+ <newline>
+ EOO
+
+ : followed
+ :
+ $* <"1abc" >>EOO
+ '1'
+ 'abc'
+ <newline>
+ EOO
+
+ : multi-digit
+ :
+ $* <"10" 2>>EOE != 0
+ stdin:1:1: error: multi-digit special variable name
+ EOE
+}