aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/function.test.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/function.test.cxx')
-rw-r--r--libbuild2/function.test.cxx57
1 files changed, 31 insertions, 26 deletions
diff --git a/libbuild2/function.test.cxx b/libbuild2/function.test.cxx
index 514ac1e..37ed5ff 100644
--- a/libbuild2/function.test.cxx
+++ b/libbuild2/function.test.cxx
@@ -12,8 +12,12 @@
#include <libbuild2/scheduler.hxx>
#include <libbuild2/function.hxx>
#include <libbuild2/variable.hxx>
+#include <libbuild2/file-cache.hxx>
#include <libbuild2/diagnostics.hxx>
+#undef NDEBUG
+#include <cassert>
+
using namespace std;
namespace build2
@@ -40,50 +44,50 @@ namespace build2
// Fake build system driver, default verbosity.
//
init_diag (1);
- init (nullptr, argv[0]);
+ init (nullptr, argv[0], true);
// Serial execution.
//
scheduler sched (1);
global_mutexes mutexes (1);
- context ctx (sched, mutexes);
+ file_cache fcache (true);
+ context ctx (sched, mutexes, fcache);
auto& functions (ctx.functions);
function_family f (functions, "dummy");
- f["fail"] = []() {fail << "failed" << endf;};
- f["fail_arg"] = [](names a) {return convert<uint64_t> (move (a[0]));};
+ f["fail"] += []() {fail << "failed" << endf;};
+ f["fail_arg"] += [](names a) {return convert<uint64_t> (move (a[0]));};
- f["nullable"] = [](names* a) {return a == nullptr;};
- f["optional"] = [](optional<names> a) {return !a;};
+ f["nullable"] += [](names* a) {return a == nullptr;};
+ f["optional"] += [](optional<names> a) {return !a;};
- f["dummy0"] = []() {return "abc";};
- f["dummy1"] = [](string s) {return s;};
- f["dummy2"] = [](uint64_t x, uint64_t y) {return x + y;};
+ f["dummy0"] += []() {return "abc";};
+ f["dummy1"] += [](string s) {return s;};
+ f["dummy2"] += [](uint64_t x, uint64_t y) {return x + y;};
- f["ambig"] = [](names a, optional<string>) {return a;};
- f["ambig"] = [](names a, optional<uint64_t>) {return a;};
+ f["ambig"] += [](names a, optional<string>) {return a;};
+ f["ambig"] += [](names a, optional<uint64_t>) {return a;};
- f["reverse"] = [](names a) {return a;};
+ f["reverse"] += [](names a) {return a;};
- f["scoped"] = [](const scope*, names a) {return a;};
- f["scoped_void"] = [](const scope*, names) {};
- f["scoped"] = &scoped;
- f["scoped_void"] = &scoped_void;
+ f["scoped"] += [](const scope*, names a) {return a;};
+ f["scoped_void"] += [](const scope*, names) {};
+ f["scoped"] += &scoped;
+ f["scoped_void"] += &scoped_void;
- f[".qual"] = []() {return "abc";};
+ f[".qual"] += []() {return "abc";};
- f[".length"] = &path::size; // Member function.
- f[".type"] = &name::type; // Data member.
+ f[".length"] += &path::size; // Member function.
+ f[".type"] += &name::type; // Data member.
- f[".abs"] = [](dir_path d) {return d.absolute ();};
+ f[".abs"] += [](dir_path d) {return d.absolute ();};
// Variadic function with first required argument of type bool. Returns
// number of arguments passed.
//
- functions.insert (
- "variadic",
+ functions.insert ("variadic", true).insert (
function_overload (
nullptr,
1,
@@ -96,8 +100,7 @@ namespace build2
// Dump arguments.
//
- functions.insert (
- "dump",
+ functions.insert ("dump", true).insert (
function_overload (
nullptr,
0,
@@ -112,7 +115,7 @@ namespace build2
else if (!a.empty ())
{
names storage;
- cout << reverse (a, storage);
+ cout << reverse (a, storage, true /* reduce */);
}
cout << endl;
}
@@ -121,7 +124,9 @@ namespace build2
try
{
- scope& s (ctx.global_scope.rw ());
+ // Use temp scope for the private variable pool.
+ //
+ temp_scope s (ctx.global_scope.rw ());
parser p (ctx);
p.parse_buildfile (cin, path_name ("buildfile"), &s, s);