aboutsummaryrefslogtreecommitdiff
path: root/unit-tests/test/script/lexer
diff options
context:
space:
mode:
Diffstat (limited to 'unit-tests/test/script/lexer')
-rw-r--r--unit-tests/test/script/lexer/buildfile6
-rw-r--r--unit-tests/test/script/lexer/command-expansion.testscript248
-rw-r--r--unit-tests/test/script/lexer/command-line.testscript208
-rw-r--r--unit-tests/test/script/lexer/description-line.testscript33
-rw-r--r--unit-tests/test/script/lexer/driver.cxx85
-rw-r--r--unit-tests/test/script/lexer/first-token.testscript97
-rw-r--r--unit-tests/test/script/lexer/second-token.testscript68
-rw-r--r--unit-tests/test/script/lexer/variable-line.testscript28
-rw-r--r--unit-tests/test/script/lexer/variable.testscript70
9 files changed, 0 insertions, 843 deletions
diff --git a/unit-tests/test/script/lexer/buildfile b/unit-tests/test/script/lexer/buildfile
deleted file mode 100644
index 190d586..0000000
--- a/unit-tests/test/script/lexer/buildfile
+++ /dev/null
@@ -1,6 +0,0 @@
-# file : unit-tests/test/script/lexer/buildfile
-# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
-# license : MIT; see accompanying LICENSE file
-
-include ../../../../build2/
-exe{driver}: {hxx cxx}{*} ../../../../build2/libue{b} testscript{*}
diff --git a/unit-tests/test/script/lexer/command-expansion.testscript b/unit-tests/test/script/lexer/command-expansion.testscript
deleted file mode 100644
index 581e13c..0000000
--- a/unit-tests/test/script/lexer/command-expansion.testscript
+++ /dev/null
@@ -1,248 +0,0 @@
-# file : unit-tests/test/script/lexer/command-expansion.testscript
-# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
-# license : MIT; see accompanying LICENSE file
-
-test.arguments = command-expansion
-
-: 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
-}
-
-: trace-redirect
-:
-{
- : 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.testscript b/unit-tests/test/script/lexer/command-line.testscript
deleted file mode 100644
index 55344b3..0000000
--- a/unit-tests/test/script/lexer/command-line.testscript
+++ /dev/null
@@ -1,208 +0,0 @@
-# file : unit-tests/test/script/lexer/command-line.testscript
-# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
-# license : MIT; see accompanying LICENSE file
-
-test.arguments = command-line
-
-: semi
-{
- : immediate
- :
- $* <"cmd;" >>EOO
- 'cmd'
- ;
- <newline>
- EOO
-
- : separated
- :
- $* <"cmd ;" >>EOO
- 'cmd'
- ;
- <newline>
- EOO
-
- : only
- :
- $* <";" >>EOO
- ;
- <newline>
- EOO
-}
-
-: colon
-:
-{
- : immediate
- :
- $* <"cmd: dsc" >>EOO
- 'cmd'
- :
- 'dsc'
- <newline>
- EOO
-
- : separated
- :
- $* <"cmd :dsc" >>EOO
- 'cmd'
- :
- 'dsc'
- <newline>
- EOO
-
- : only
- :
- $* <":" >>EOO
- :
- <newline>
- EOO
-}
-
-: redirect
-:
-{
- : pass
- :
- $* <"cmd <| 1>|" >>EOO
- 'cmd'
- <|
- '1'
- >|
- <newline>
- EOO
-
- : null
- :
- $* <"cmd <- 1>-" >>EOO
- 'cmd'
- <-
- '1'
- >-
- <newline>
- EOO
-
- : trace
- :
- $* <"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-cmp
- :
- $* <"cmd <<<in >>>out 2>>>err" >>EOO
- 'cmd'
- <<<
- 'in'
- >>>
- 'out'
- '2'
- >>>
- 'err'
- <newline>
- EOO
-
- : file-write
- :
- $* <"cmd >=out 2>+err" >>EOO
- 'cmd'
- >=
- 'out'
- '2'
- >+
- 'err'
- <newline>
- EOO
-}
-
-: cleanup
-:
-{
- : 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.testscript b/unit-tests/test/script/lexer/description-line.testscript
deleted file mode 100644
index dc9fd9c..0000000
--- a/unit-tests/test/script/lexer/description-line.testscript
+++ /dev/null
@@ -1,33 +0,0 @@
-# file : unit-tests/test/script/lexer/description-line.testscript
-# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
-# license : MIT; see accompanying LICENSE file
-
-test.arguments = description-line
-
-: full
-:
-$* <" foo bar " >>EOO
-' foo bar '
-<newline>
-EOO
-
-: space
-:
-$* <" " >>EOO
-' '
-<newline>
-EOO
-
-: empty
-:
-$* <"" >>EOO
-<newline>
-EOO
-
-: eof
-:
-$* <:"foo" >>EOO 2>>EOE != 0
-'foo'
-EOO
-stdin:1:4: error: expected newline at the end of description line
-EOE
diff --git a/unit-tests/test/script/lexer/driver.cxx b/unit-tests/test/script/lexer/driver.cxx
deleted file mode 100644
index 14d142c..0000000
--- a/unit-tests/test/script/lexer/driver.cxx
+++ /dev/null
@@ -1,85 +0,0 @@
-// file : unit-tests/test/script/lexer/driver.cxx -*- C++ -*-
-// copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
-// license : MIT; see accompanying LICENSE file
-
-#include <cassert>
-#include <iostream>
-
-#include <build2/types.hxx>
-#include <build2/utility.hxx>
-
-#include <build2/test/script/token.hxx>
-#include <build2/test/script/lexer.hxx>
-
-using namespace std;
-
-namespace build2
-{
- namespace test
- {
- namespace script
- {
- // Usage: argv[0] <lexer-mode>
- //
- int
- main (int argc, char* argv[])
- {
- lexer_mode m;
- {
- assert (argc == 2);
- string s (argv[1]);
-
- if (s == "command-line") m = lexer_mode::command_line;
- else if (s == "first-token") m = lexer_mode::first_token;
- else if (s == "second-token") m = lexer_mode::second_token;
- else if (s == "variable-line") m = lexer_mode::variable_line;
- else if (s == "command-expansion") m = lexer_mode::command_expansion;
- else if (s == "here-line-single") m = lexer_mode::here_line_single;
- else if (s == "here-line-double") m = lexer_mode::here_line_double;
- else if (s == "description-line") m = lexer_mode::description_line;
- else if (s == "variable") m = lexer_mode::variable;
- else assert (false);
- }
-
- try
- {
- cin.exceptions (istream::failbit | istream::badbit);
-
- // Some modes auto-expire so we need something underneath.
- //
- bool u (m == lexer_mode::first_token ||
- m == lexer_mode::second_token ||
- m == lexer_mode::variable_line ||
- m == lexer_mode::description_line ||
- m == lexer_mode::variable);
-
- lexer l (cin, path ("stdin"), u ? lexer_mode::command_line : m);
- if (u)
- l.mode (m);
-
- // No use printing eos since we will either get it or loop forever.
- //
- for (token t (l.next ()); t.type != token_type::eos; t = l.next ())
- {
- // Print each token on a separate line without quoting operators.
- //
- t.printer (cout, t, false);
- cout << endl;
- }
- }
- catch (const failed&)
- {
- return 1;
- }
-
- return 0;
- }
- }
- }
-}
-
-int
-main (int argc, char* argv[])
-{
- return build2::test::script::main (argc, argv);
-}
diff --git a/unit-tests/test/script/lexer/first-token.testscript b/unit-tests/test/script/lexer/first-token.testscript
deleted file mode 100644
index 45cb085..0000000
--- a/unit-tests/test/script/lexer/first-token.testscript
+++ /dev/null
@@ -1,97 +0,0 @@
-# file : unit-tests/test/script/lexer/first-token.testscript
-# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
-# license : MIT; see accompanying LICENSE file
-
-# Note: this mode auto-expires after each token.
-#
-test.arguments = first-token
-
-: dot
-:
-$* <"." >>EOO
-.
-<newline>
-EOO
-
-: semi
-:
-$* <";" >>EOO
-;
-<newline>
-EOO
-
-: colon
-:
-$* <":" >>EOO
-:
-<newline>
-EOO
-
-: lcbrace
-:
-$* <"{" >>EOO
-{
-<newline>
-EOO
-
-: rcbrace
-:
-$* <"}" >>EOO
-}
-<newline>
-EOO
-
-: setup
-:
-$* <"+foo" >>EOO
-+
-'foo'
-<newline>
-EOO
-
-: tdown
-:
-$* <"- foo" >>EOO
--
-'foo'
-<newline>
-EOO
-
-: plus-leading
-:
-$* <"foo+bar" >>EOO
-'foo+bar'
-<newline>
-EOO
-
-: minus-leading
-:
-$* <"foo- x" >>EOO
-'foo-'
-'x'
-<newline>
-EOO
-
-: assign
-:
-$* <"foo=" >>EOO
-'foo'
-'='
-<newline>
-EOO
-
-: append
-:
-$* <"foo+=" >>EOO
-'foo'
-'+='
-<newline>
-EOO
-
-: prepend
-:
-$* <"foo=+" >>EOO
-'foo'
-'=+'
-<newline>
-EOO
diff --git a/unit-tests/test/script/lexer/second-token.testscript b/unit-tests/test/script/lexer/second-token.testscript
deleted file mode 100644
index e6a72d3..0000000
--- a/unit-tests/test/script/lexer/second-token.testscript
+++ /dev/null
@@ -1,68 +0,0 @@
-# file : unit-tests/test/script/lexer/second-token.testscript
-# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
-# license : MIT; see accompanying LICENSE file
-
-# Note: this mode auto-expires after each token.
-#
-test.arguments = second-token
-
-: semi
-:
-$* <";" >>EOO
-;
-<newline>
-EOO
-
-: colon
-:
-$* <":" >>EOO
-:
-<newline>
-EOO
-
-: assign
-:
-$* <"=foo" >>EOO
-=
-'foo'
-<newline>
-EOO
-
-: append
-:
-$* <"+= foo" >>EOO
-+=
-'foo'
-<newline>
-EOO
-
-: prepend
-:
-$* <" =+ foo" >>EOO
-=+
-'foo'
-<newline>
-EOO
-
-: assign-leading
-:
-$* <"foo=bar" >>EOO
-'foo=bar'
-<newline>
-EOO
-
-: append-leading
-:
-$* <"foo+= bar" >>EOO
-'foo+='
-'bar'
-<newline>
-EOO
-
-: prepend-leading
-:
-$* <"foo =+bar" >>EOO
-'foo'
-'=+bar'
-<newline>
-EOO
diff --git a/unit-tests/test/script/lexer/variable-line.testscript b/unit-tests/test/script/lexer/variable-line.testscript
deleted file mode 100644
index ffbcefb..0000000
--- a/unit-tests/test/script/lexer/variable-line.testscript
+++ /dev/null
@@ -1,28 +0,0 @@
-# file : unit-tests/test/script/lexer/variable-line.testscript
-# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
-# license : MIT; see accompanying LICENSE file
-
-test.arguments = variable-line
-
-: semi
-:
-$* <"cmd;" >>EOO
-'cmd'
-;
-<newline>
-EOO
-
-: semi-separated
-:
-$* <"cmd ;" >>EOO
-'cmd'
-;
-<newline>
-EOO
-
-: semi-only
-:
-$* <";" >>EOO
-;
-<newline>
-EOO
diff --git a/unit-tests/test/script/lexer/variable.testscript b/unit-tests/test/script/lexer/variable.testscript
deleted file mode 100644
index 243a9c4..0000000
--- a/unit-tests/test/script/lexer/variable.testscript
+++ /dev/null
@@ -1,70 +0,0 @@
-# file : unit-tests/test/script/lexer/variable.testscript
-# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
-# license : MIT; see accompanying LICENSE file
-
-# Test handling custom variable names ($*, $~, $NN).
-#
-test.arguments = variable
-
-: 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
-}