diff options
Diffstat (limited to 'tests/build')
-rw-r--r-- | tests/build/lexer/driver.cxx | 4 | ||||
-rw-r--r-- | tests/build/parser/driver.cxx | 70 |
2 files changed, 73 insertions, 1 deletions
diff --git a/tests/build/lexer/driver.cxx b/tests/build/lexer/driver.cxx index b1af9d9..e329b1c 100644 --- a/tests/build/lexer/driver.cxx +++ b/tests/build/lexer/driver.cxx @@ -71,6 +71,8 @@ main () tokens ({"foo", ":", "\n", "bar", ""})); } +ostream cnull (nullptr); + static tokens lex (const char* s) { @@ -78,7 +80,7 @@ lex (const char* s) istringstream is (s); is.exceptions (istream::failbit | istream::badbit); - lexer l (is, ""); + lexer l (is, "", cnull); try { diff --git a/tests/build/parser/driver.cxx b/tests/build/parser/driver.cxx new file mode 100644 index 0000000..4ba589d --- /dev/null +++ b/tests/build/parser/driver.cxx @@ -0,0 +1,70 @@ +// file : tests/build/parser/driver.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +#include <cassert> +#include <sstream> +#include <iostream> + +#include <build/path> +#include <build/lexer> +#include <build/parser> + +using namespace std; +using namespace build; + +static bool +parse (const char*); + +int +main () +{ + 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 lib{fox}")); + + assert (!parse (":")); + assert (!parse ("foo")); + assert (!parse ("{")); + assert (!parse ("{foo:")); + assert (!parse ("{foo{:")); + assert (!parse ("foo: bar:")); + assert (!parse ("exe{foo:")); +} + +ostream cnull (nullptr); + +static bool +parse (const char* s) +{ + istringstream is (s); + + is.exceptions (istream::failbit | istream::badbit); + parser p (cnull); + + try + { + p.parse (is, path ()); + } + catch (const parser_error&) + { + return false; + } + + return true; +} |