diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-06-18 17:40:06 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-06-18 17:40:06 +0200 |
commit | 82ad80de9a967f253026c4874b47486c69402288 (patch) | |
tree | 8bdc35b1a59e324b401291d7ea015cc0deb00c7d /tests/build/parser | |
parent | 902f3763af4931c5c04c47d10e4d24dba96487cd (diff) |
Add headers to buildfiles, move tests/build/ to tests/
Diffstat (limited to 'tests/build/parser')
-rw-r--r-- | tests/build/parser/buildfile | 2 | ||||
-rw-r--r-- | tests/build/parser/driver.cxx | 102 |
2 files changed, 0 insertions, 104 deletions
diff --git a/tests/build/parser/buildfile b/tests/build/parser/buildfile deleted file mode 100644 index c924dcb..0000000 --- a/tests/build/parser/buildfile +++ /dev/null @@ -1,2 +0,0 @@ -exe{driver}: cxx{driver ../../../build/{lexer parser scope target native \ - prerequisite context diagnostics utility path timestamp}} diff --git a/tests/build/parser/driver.cxx b/tests/build/parser/driver.cxx deleted file mode 100644 index fef2f41..0000000 --- a/tests/build/parser/driver.cxx +++ /dev/null @@ -1,102 +0,0 @@ -// file : tests/build/parser/driver.cxx -*- C++ -*- -// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd -// license : MIT; see accompanying LICENSE file - -#include <cassert> -#include <sstream> -#include <iostream> - -#include <build/types> -#include <build/scope> -#include <build/target> -#include <build/native> - -#include <build/lexer> -#include <build/parser> - -using namespace std; -using namespace build; - -static bool -parse (const char*); - -int -main () -{ - ostream cnull (nullptr); - diag_stream = &cnull; - - target_types.insert (file::static_type); - target_types.insert (exe::static_type); - target_types.insert (obj::static_type); - - assert (parse ("")); - assert (parse ("foo:")); - assert (parse ("foo bar:")); - assert (parse ("foo:\nbar:")); - assert (parse ("foo: bar")); - assert (parse ("foo: bar baz")); - assert (parse ("foo bar: baz biz")); - - assert (parse ("{foo}:")); - assert (parse ("{foo bar}:")); - assert (parse ("{{foo bar}}:")); - assert (parse ("{{foo bar} {baz} {biz fox} fix}:")); - - assert (parse ("exe{foo}:")); - assert (parse ("exe{foo bar}:")); - assert (parse ("{exe{foo bar}}:")); - assert (parse ("exe{{foo bar} fox}:")); - assert (parse ("exe{foo}: obj{bar baz} biz.o file{fox}")); - - assert (!parse (":")); - assert (!parse ("foo")); - assert (!parse ("{")); - assert (!parse ("{foo:")); - assert (!parse ("{foo{:")); - assert (!parse ("foo: bar:")); - assert (!parse ("exe{foo:")); - - // Directory prefix. - // - assert (parse ("../{foo}: ../{bar}")); - assert (parse ("../exe{foo}: ../obj{bar}")); - assert (!parse ("../exe{exe{foo}}:")); - - // Directory scope. - // - assert (parse ("test/:\n{\n}")); - assert (parse ("test/:\n{\n}\n")); - assert (parse ("test/:\n{\nfoo:bar\n}")); - assert (parse ("test/:\n{\nfoo:bar\n}")); - assert (parse ("test/:\n{\nmore/:\n{\n}\n}")); - assert (parse ("test/:\n{\nmore/:\n{\nfoo:{bar baz}\n}\n}")); - - assert (!parse ("test/:\n{")); - assert (!parse ("test/:\n{\n")); - assert (!parse ("test/:\n{\n:")); - assert (!parse ("test/:\n{\n} foo: bar\n")); - assert (!parse ("test/ foo:\n{\n}")); - assert (!parse ("test foo/:\n{\n}")); - assert (!parse ("test/ foo/:\n{\n}")); -} - -static bool -parse (const char* s) -{ - istringstream is (s); - - is.exceptions (istream::failbit | istream::badbit); - parser p; - - try - { - p.parse (is, path (), scopes[path::current ()]); - } - catch (const failed&) - { - return false; - } - - return true; -} |