From 77410b0cdde47219d6c6a36533fcb9354f17c3dd Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 6 Mar 2019 23:06:30 +0300 Subject: Use new setup for unit tests --- unit-tests/cc/lexer/buildfile | 6 - unit-tests/cc/lexer/char-literal.testscript | 67 ---------- unit-tests/cc/lexer/comment.testscript | 88 ------------- unit-tests/cc/lexer/driver.cxx | 80 ------------ unit-tests/cc/lexer/line.testscript | 67 ---------- unit-tests/cc/lexer/number.testscript | 48 ------- unit-tests/cc/lexer/preprocessor.testscript | 73 ----------- unit-tests/cc/lexer/raw-string-literal.testscript | 90 ------------- unit-tests/cc/lexer/string-literal.testscript | 65 ---------- unit-tests/cc/parser/buildfile | 6 - unit-tests/cc/parser/driver.cxx | 66 ---------- unit-tests/cc/parser/module.testscript | 149 ---------------------- 12 files changed, 805 deletions(-) delete mode 100644 unit-tests/cc/lexer/buildfile delete mode 100644 unit-tests/cc/lexer/char-literal.testscript delete mode 100644 unit-tests/cc/lexer/comment.testscript delete mode 100644 unit-tests/cc/lexer/driver.cxx delete mode 100644 unit-tests/cc/lexer/line.testscript delete mode 100644 unit-tests/cc/lexer/number.testscript delete mode 100644 unit-tests/cc/lexer/preprocessor.testscript delete mode 100644 unit-tests/cc/lexer/raw-string-literal.testscript delete mode 100644 unit-tests/cc/lexer/string-literal.testscript delete mode 100644 unit-tests/cc/parser/buildfile delete mode 100644 unit-tests/cc/parser/driver.cxx delete mode 100644 unit-tests/cc/parser/module.testscript (limited to 'unit-tests/cc') diff --git a/unit-tests/cc/lexer/buildfile b/unit-tests/cc/lexer/buildfile deleted file mode 100644 index 4eaef44..0000000 --- a/unit-tests/cc/lexer/buildfile +++ /dev/null @@ -1,6 +0,0 @@ -# file : unit-tests/cc/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/cc/lexer/char-literal.testscript b/unit-tests/cc/lexer/char-literal.testscript deleted file mode 100644 index cbcb462..0000000 --- a/unit-tests/cc/lexer/char-literal.testscript +++ /dev/null @@ -1,67 +0,0 @@ -# file : unit-tests/cc/lexer/char-literal.testscript -# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test character literals. -# - -: normal -: -$* <>EOO -'a' -'aa' -'"' -EOI - - - -EOO - -: prefix -: -$* <>EOO -L'a' -U'a' -u'a' -u8'a' -u8R'a' -EOI - - - - -'u8R' - -EOO - -: suffix -: -$* <>EOO -'a'x -'a'_X123 -EOI - - -EOO - -: escape -: -$* <>EOO -'\'' -'\\' -'\\\'' -'\n' -U'\U0001f34c' -EOI - - - - - -EOO - -: unterminated -: -$* <"'a" 2>>EOE != 0 -stdin:1:1: error: unterminated character literal -EOE diff --git a/unit-tests/cc/lexer/comment.testscript b/unit-tests/cc/lexer/comment.testscript deleted file mode 100644 index 347c2e7..0000000 --- a/unit-tests/cc/lexer/comment.testscript +++ /dev/null @@ -1,88 +0,0 @@ -# file : unit-tests/cc/lexer/comment.testscript -# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test C and C++ comments. -# - -: c-comment -: -$* <"';'" -// /* -; -// */ -EOI - -: c-unterminated -: -$* <>EOE != 0 -/* -comment -EOI -stdin:1:2: error: unterminated comment -EOE - -: cxx-unterminated -: -$* <<:EOI -// comment -EOI - -: in-char-literal -: -$* <>EOO -'//' -'/*'*/ -EOI - - - - -EOO - -: in-string-literal -: -$* <>EOO -"//foo" -"/*"*/ -EOI - - - - -EOO - -: in-raw-string-literal -: -$* <>EOO -R"X( -// foo -/* bar -)X"*/ -EOI - - - -EOO diff --git a/unit-tests/cc/lexer/driver.cxx b/unit-tests/cc/lexer/driver.cxx deleted file mode 100644 index ebbb9ab..0000000 --- a/unit-tests/cc/lexer/driver.cxx +++ /dev/null @@ -1,80 +0,0 @@ -// file : unit-tests/cc/lexer/driver.cxx -*- C++ -*- -// copyright : Copyright (c) 2014-2019 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#include -#include - -#include -#include - -#include - -using namespace std; -using namespace butl; - -namespace build2 -{ - namespace cc - { - // Usage: argv[0] [-l] [] - // - int - main (int argc, char* argv[]) - { - bool loc (false); - const char* file (nullptr); - - for (int i (1); i != argc; ++i) - { - string a (argv[i]); - - if (a == "-l") - loc = true; - else - { - file = argv[i]; - break; - } - } - - try - { - ifdstream is; - if (file != nullptr) - is.open (file); - else - { - file = "stdin"; - is.open (fddup (stdin_fd ())); - } - - lexer l (is, path (file)); - - // No use printing eos since we will either get it or loop forever. - // - for (token t; l.next (t) != token_type::eos; ) - { - cout << t; - - if (loc) - cout << ' ' << t.file << ':' << t.line << ':' << t.column; - - cout << endl; - } - } - catch (const failed&) - { - return 1; - } - - return 0; - } - } -} - -int -main (int argc, char* argv[]) -{ - return build2::cc::main (argc, argv); -} diff --git a/unit-tests/cc/lexer/line.testscript b/unit-tests/cc/lexer/line.testscript deleted file mode 100644 index 9dcd7e3..0000000 --- a/unit-tests/cc/lexer/line.testscript +++ /dev/null @@ -1,67 +0,0 @@ -# file : unit-tests/cc/lexer/line.testscript -# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test line continuations. -# - -: identifier -: -$* <"'foo123'" -fo\ -o\ -1\ -2\ -3 -EOI - -: punctuation -: -$* <'' -.\ -.\ -. -EOI - -: c-comment -: -$* <>EOO -\abc -EOI - -'abc' -EOO - -: multiple -: -$* <>EOO -\\ -EOI - -EOO - -: unterminated -: -$* <<:EOI >'' -\ -EOI diff --git a/unit-tests/cc/lexer/number.testscript b/unit-tests/cc/lexer/number.testscript deleted file mode 100644 index 0b4c888..0000000 --- a/unit-tests/cc/lexer/number.testscript +++ /dev/null @@ -1,48 +0,0 @@ -# file : unit-tests/cc/lexer/number.testscript -# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test numbers. -# - -$* <'1' >'' -$* <'.1' >'' -$* <'1.' >'' - -$* <'0b101' >'' -$* <'0123' >'' -$* <'0X12AB' >'' - -$* <'1e10' >'' -$* <'1E+10' >'' -$* <'0x1.p10' >'' -$* <'0x1.P-10' >'' - -$* <"123'456" >'' -$* <"0xff00'00ff" >'' - -$* <'123f' >'' -$* <'123UL' >'' -$* <'123_X' >'' - -: separate-punctuation -: -$* <'123;' >>EOO - -';' -EOO - -: separate-plus-minus -: -$* <'1.0_a+2.0' >>EOO - - - -EOO - -: separate-whitespace -: -$* <'123 abc' >>EOO - -'abc' -EOO diff --git a/unit-tests/cc/lexer/preprocessor.testscript b/unit-tests/cc/lexer/preprocessor.testscript deleted file mode 100644 index e826144..0000000 --- a/unit-tests/cc/lexer/preprocessor.testscript +++ /dev/null @@ -1,73 +0,0 @@ -# file : unit-tests/cc/lexer/preprocessor.testscript -# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test preprocessor lines. -# - -: normal -: -$* <>EOO -; -# 1 "test.cxx" 2 -; - ; -# 4 -; -#line 8 "z:\\tmp\\test.hxx" -; -#line 10 -; -# 5 "test.cxx" -; -EOI -';' stdin:1:1 -';' test.cxx:1:1 -';' test.cxx:2:3 -';' test.cxx:4:1 -';' z:\tmp\test.hxx:8:1 -';' z:\tmp\test.hxx:10:1 -';' test.cxx:5:1 -EOO - -: include -: -$* <>EOE != 0 -#include -EOI -stdin:1:1: error: unexpected #include directive -EOE - -: nested -: -$* <>EOO -#define FOO(x) #y -; -EOI -';' -EOO diff --git a/unit-tests/cc/lexer/raw-string-literal.testscript b/unit-tests/cc/lexer/raw-string-literal.testscript deleted file mode 100644 index 4ab08f7..0000000 --- a/unit-tests/cc/lexer/raw-string-literal.testscript +++ /dev/null @@ -1,90 +0,0 @@ -# file : unit-tests/cc/lexer/raw-string-literal.testscript -# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test raw string literals. -# - -: normal -: -$* <>EOO -R"()" -R"(ab)" -R"(a"b)" -R"(a)b)" -R"%(a%)b)%" -R"X(a - b)X" -R"X(a\ - b)X" -EOI - - - - - - - -EOO - -: prefix -: -$* <>EOO -LR"(ab)" -UR"(ab)" -uR"(ab)" -u8R"(ab)" -EOI - - - - -EOO - -: suffix -: -$* <>EOO -R"(ab)"x -R"(ab)"_X123 -EOI - - -EOO - -: escape -: -$* <>EOO -R"(\)" -EOI - -EOO - -: invalid-no-paren -: -$* <'R"a"' 2>>EOE != 0 -stdin:1:2: error: invalid raw string literal -EOE - -: invalid-paren -: -$* <'R")()("' 2>>EOE != 0 -stdin:1:2: error: invalid raw string literal -EOE - -: invalid-unterminated-paren -: -$* <'R"(abc"' 2>>EOE != 0 -stdin:1:2: error: invalid raw string literal -EOE - -: invalid-unterminated-delimiter -: -$* <'R"X(abc)"' 2>>EOE != 0 -stdin:1:2: error: invalid raw string literal -EOE - -: invalid-unterminated-quote -: -$* <'R"X(abc)X' 2>>EOE != 0 -stdin:1:2: error: invalid raw string literal -EOE diff --git a/unit-tests/cc/lexer/string-literal.testscript b/unit-tests/cc/lexer/string-literal.testscript deleted file mode 100644 index db3798f..0000000 --- a/unit-tests/cc/lexer/string-literal.testscript +++ /dev/null @@ -1,65 +0,0 @@ -# file : unit-tests/cc/lexer/string-literal.testscript -# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test string literals (except raw). -# - -: normal -: -$* <>EOO -"aa" -"'" -"a""b" -EOI - - - - -EOO - -: prefix -: -$* <>EOO -L"ab" -U"ab" -u"ab" -u8"ab" -EOI - - - - -EOO - -: suffix -: -$* <>EOO -"ab"x -"ab"_X123 -EOI - - -EOO - -: escape -: -$* <>EOO -"\"\"" -"\\\\" -"\\\"\\" -"\n\t" -U"a\U0001f34c" -EOI - - - - - -EOO - -: unterminated -: -$* <'"ab' 2>>EOE != 0 -stdin:1:1: error: unterminated string literal -EOE diff --git a/unit-tests/cc/parser/buildfile b/unit-tests/cc/parser/buildfile deleted file mode 100644 index d9e3e28..0000000 --- a/unit-tests/cc/parser/buildfile +++ /dev/null @@ -1,6 +0,0 @@ -# file : unit-tests/cc/parser/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/cc/parser/driver.cxx b/unit-tests/cc/parser/driver.cxx deleted file mode 100644 index 19a2133..0000000 --- a/unit-tests/cc/parser/driver.cxx +++ /dev/null @@ -1,66 +0,0 @@ -// file : unit-tests/cc/parser/driver.cxx -*- C++ -*- -// copyright : Copyright (c) 2014-2019 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#include -#include - -#include -#include - -#include - -using namespace std; -using namespace butl; - -namespace build2 -{ - namespace cc - { - // Usage: argv[0] [] - // - int - main (int argc, char* argv[]) - { - try - { - const char* file; - - ifdstream is; - if (argc > 1) - { - file = argv[1]; - is.open (file); - } - else - { - file = "stdin"; - is.open (fddup (stdin_fd ())); - } - - parser p; - translation_unit u (p.parse (is, path (file))); - - for (const module_import& m: u.mod.imports) - cout << (m.exported ? "export " : "") - << "import " << m.name << ';' << endl; - - if (!u.mod.name.empty ()) - cout << (u.mod.iface ? "export " : "") - << "module " << u.mod.name << ';' << endl; - } - catch (const failed&) - { - return 1; - } - - return 0; - } - } -} - -int -main (int argc, char* argv[]) -{ - return build2::cc::main (argc, argv); -} diff --git a/unit-tests/cc/parser/module.testscript b/unit-tests/cc/parser/module.testscript deleted file mode 100644 index dc7f3e4..0000000 --- a/unit-tests/cc/parser/module.testscript +++ /dev/null @@ -1,149 +0,0 @@ -# file : unit-tests/cc/parser/module.testscript -# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd -# license : MIT; see accompanying LICENSE file - -# Test C++ module constructs. -# - -: import -: -$* <>EOI -import foo; -import foo.bar; -import foo.bar.baz; -EOI - -: module-implementation -: -$* <>EOI -module foo; -EOI - -: module-interface -: -$* <>EOI -export module foo; -EOI - -: export-imported -: -$* <>EOO -export import foo; -EOI -export import foo; -EOO - -: export-imported-block -: -$* <>EOO -import bar; - -export {import foo;} - -export -{ - namespace foo - { - class c {}; - } - - template int f (); - - import bar; -} -EOI -export import bar; -export import foo; -EOO - -: non-module -: -$* <>EOO -import foo [[export({import})]]; -module bar [[module({module})]]; -EOI -import foo; -module bar; -EOO - -: import-duplicate -: -$* <>EOO -import foo; -import bar.baz; -import foo; -import bar . baz; -EOI -import foo; -import bar.baz; -EOO - -: brace-missing -: -$* <>EOE != 0 -export -{ - class foo - { - //}; - module foo; -} -EOI -stdin:8:1: error: {}-imbalance detected -EOE - -: brace-stray -: -$* <>EOE != 0 -export -{ - class foo - { - };} -} -module foo; -EOI -stdin:6:1: error: {}-imbalance detected -EOE - -: import-missing-name -: -$* <>EOE != 0 -import ; -EOI -stdin:1:8: error: module name expected instead of ';' -EOE - -: module-missing-name -: -$* <>EOE != 0 -module ; -EOI -stdin:1:1: error: module declaration expected after leading module marker -EOE - -: import-missing-semi -: -$* <>EOE != 0 -import foo -EOI -stdin:2:1: error: ';' expected instead of -EOE - -: module-missing-semi -: -$* <>EOE != 0 -export module foo -EOI -stdin:2:1: error: ';' expected instead of -EOE -- cgit v1.1