diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2019-03-06 23:06:30 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2019-03-08 16:42:31 +0300 |
commit | 77410b0cdde47219d6c6a36533fcb9354f17c3dd (patch) | |
tree | 703c39f3bc81792fabaf81769035f01a08cf6a2f /unit-tests/lexer | |
parent | 8ca10194e206a181797ffb7a73dd2deee12ac753 (diff) |
Use new setup for unit tests
Diffstat (limited to 'unit-tests/lexer')
-rw-r--r-- | unit-tests/lexer/buildfile | 6 | ||||
-rw-r--r-- | unit-tests/lexer/buildspec.testscript | 16 | ||||
-rw-r--r-- | unit-tests/lexer/comment.testscript | 139 | ||||
-rw-r--r-- | unit-tests/lexer/driver.cxx | 98 | ||||
-rw-r--r-- | unit-tests/lexer/eval.testscript | 76 | ||||
-rw-r--r-- | unit-tests/lexer/quoting.testscript | 108 |
6 files changed, 0 insertions, 443 deletions
diff --git a/unit-tests/lexer/buildfile b/unit-tests/lexer/buildfile deleted file mode 100644 index b7cc4c6..0000000 --- a/unit-tests/lexer/buildfile +++ /dev/null @@ -1,6 +0,0 @@ -# file : unit-tests/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/lexer/buildspec.testscript b/unit-tests/lexer/buildspec.testscript deleted file mode 100644 index 71568ae..0000000 --- a/unit-tests/lexer/buildspec.testscript +++ /dev/null @@ -1,16 +0,0 @@ -# file : unit-tests/lexer/buildspec.testscript -# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -test.arguments = buildspec - -: punctuation -: -$* <:'x,x(x)' >>EOO -'x' -, -'x' - ( -'x' -) -EOO diff --git a/unit-tests/lexer/comment.testscript b/unit-tests/lexer/comment.testscript deleted file mode 100644 index 44e1866..0000000 --- a/unit-tests/lexer/comment.testscript +++ /dev/null @@ -1,139 +0,0 @@ -# file : unit-tests/lexer/comment.testscript -# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -: single-line -: -{ - : only - : - $* <<EOI >>:EOO - # comment - EOI - EOO - - : first - : - $* <<EOI >>EOO - # comment - foo - EOI - 'foo' - <newline> - EOO - - : last - : - $* <<EOI >>EOO - foo - # comment - EOI - 'foo' - <newline> - EOO - - : few - : - $* <<EOI >>EOO - foo - # comment - # comment - EOI - 'foo' - <newline> - EOO - - : cont - : - $* <<EOI >>EOO - foo - # comment\\ - bar - EOI - 'foo' - <newline> - 'bar' - <newline> - EOO - - : same - : - $* <<EOI >>EOO - foo # comment - bar # comment - EOI - 'foo' - <newline> - 'bar' - <newline> - EOO -} - -: multi-line -: -{ - : only - : - $* <<EOI >>:EOO - #\ - comment - comment - #\ - EOI - EOO - - : empty - : - $* <<EOI >>:EOO - #\ - #\ - EOI - EOO - - : start-same - : - $* <<EOI >>EOO - foo #\ - comment - comment - #\ - EOI - 'foo' - <newline> - EOO - - : end-same - : - $* <<EOI >>EOO - #\ - comment - comment - foo #\ - bar - EOI - 'bar' - <newline> - EOO - - : end-not - : - $* <<EOI >>EOO - #\ - comment - #\ not an end - foo #\ - bar - EOI - 'bar' - <newline> - EOO - - : unterm - : - $* <<EOI 2>>EOE != 0 - #\ - comment - EOI - stdin:3:1: error: unterminated multi-line comment - EOE -} diff --git a/unit-tests/lexer/driver.cxx b/unit-tests/lexer/driver.cxx deleted file mode 100644 index a5cdb8d..0000000 --- a/unit-tests/lexer/driver.cxx +++ /dev/null @@ -1,98 +0,0 @@ -// file : unit-tests/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/token.hxx> -#include <build2/lexer.hxx> - -using namespace std; - -namespace build2 -{ - // Usage: argv[0] [-q] [<lexer-mode>] - // - int - main (int argc, char* argv[]) - { - bool quote (false); - lexer_mode m (lexer_mode::normal); - - for (int i (1); i != argc; ++i) - { - string a (argv[i]); - - if (a == "-q") - quote = true; - else - { - if (a == "normal") m = lexer_mode::normal; - else if (a == "variable") m = lexer_mode::variable; - else if (a == "value") m = lexer_mode::value; - else if (a == "attribute") m = lexer_mode::attribute; - else if (a == "eval") m = lexer_mode::eval; - else if (a == "buildspec") m = lexer_mode::buildspec; - else assert (false); - break; - } - } - - try - { - cin.exceptions (istream::failbit | istream::badbit); - - // Most alternative modes auto-expire so we need something underneath. - // - lexer l (cin, path ("stdin")); - - if (m != lexer_mode::normal) - 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 ()) - { - if (t.separated && t.type != token_type::newline) - cout << ' '; - - // Print each token on a separate line without quoting operators. - // - t.printer (cout, t, false); - - if (quote) - { - char q ('\0'); - switch (t.qtype) - { - case quote_type::single: q = 'S'; break; - case quote_type::double_: q = 'D'; break; - case quote_type::mixed: q = 'M'; break; - case quote_type::unquoted: break; - } - - if (q != '\0') - cout << " [" << q << (t.qcomp ? "/C" : "/P") << ']'; - } - - cout << endl; - } - } - catch (const failed&) - { - return 1; - } - - return 0; - } -} - -int -main (int argc, char* argv[]) -{ - return build2::main (argc, argv); -} diff --git a/unit-tests/lexer/eval.testscript b/unit-tests/lexer/eval.testscript deleted file mode 100644 index 6768756..0000000 --- a/unit-tests/lexer/eval.testscript +++ /dev/null @@ -1,76 +0,0 @@ -# file : unit-tests/lexer/eval.testscript -# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -test.arguments = eval - -: punctuation -: -$* <:'x:x{x}x[x]x$x?x,x(x)' >>EOO -'x' -: -'x' -{ -'x' -} -'x' -[ -'x' -] -'x' -$ -'x' -? -'x' -, -'x' -( -'x' -) -EOO - -: logical -: -$* <:'x|x||x&x&&x!x!!x)' >>EOO -'x|x' -|| -'x&x' -&& -'x' -! -'x' -! -! -'x' -) -EOO - -: comparison -: -$* <:'x=x==x!=x<x<=x>x>=)' >>EOO -'x=x' -== -'x' -!= -'x' -< -'x' -<= -'x' -> -'x' ->= -) -EOO - -: newline -: -$* <'x' >- 2>>EOE != 0 -stdin:1:2: error: newline in evaluation context -EOE - -: eof -: -$* <:'' 2>>EOE != 0 -stdin:1:1: error: unterminated evaluation context -EOE diff --git a/unit-tests/lexer/quoting.testscript b/unit-tests/lexer/quoting.testscript deleted file mode 100644 index e9767f2..0000000 --- a/unit-tests/lexer/quoting.testscript +++ /dev/null @@ -1,108 +0,0 @@ -# file : unit-tests/lexer/quoting.testscript -# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -test.options += -q - -: unquoted -: -$* <'foo' >>EOO -'foo' -<newline> -EOO - -: comp -: -{ - : single - : - $* <":'foo':" >>EOO - : - 'foo' [S/C] - : - <newline> - EOO - - : double - : - $* <':"foo":' >>EOO - : - 'foo' [D/C] - : - <newline> - EOO - - : single-empty - : - $* <"''" >>EOO - '' [S/C] - <newline> - EOO - - : double-empty - : - $* <'""' >>EOO - '' [D/C] - <newline> - EOO -} - -: part -{ - : quoted - { - : start - : Token start already quoted - : - $* <'"$foo"' >>EOO - '' [D/P] - $ [D/C] - 'foo' [D/P] - <newline> - EOO - - : end - : Token end still quoted - : - $* <'"foo$"' >>EOO - 'foo' [D/P] - $ [D/C] - '' [D/P] - <newline> - EOO - } - - : unquoted - { - : start - : Token starts with unquoted character - : - $* <'f"oo"' >>EOO - 'foo' [D/P] - <newline> - EOO - - : end - : Token continous with unquoted character - : - $* <'"fo"o' >>EOO - 'foo' [D/P] - <newline> - EOO - - : escape - : Token continous with unquoted escaped character - : - $* <'"fo"\"' >>EOO - 'fo"' [D/P] - <newline> - EOO - } -} - -: mixed -: -$* <"\"fo\"'o'" >>EOO -'foo' [M/P] -<newline> -EOO |