From 4168cda2363f3d796d0b9922852e249aac3131ba Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 4 Dec 2020 08:39:35 +0200 Subject: Mark Buildfile functions as pure or impure --- libbuild2/function.test.cxx | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'libbuild2/function.test.cxx') diff --git a/libbuild2/function.test.cxx b/libbuild2/function.test.cxx index 514ac1e..f8a2c16 100644 --- a/libbuild2/function.test.cxx +++ b/libbuild2/function.test.cxx @@ -52,38 +52,37 @@ namespace build2 function_family f (functions, "dummy"); - f["fail"] = []() {fail << "failed" << endf;}; - f["fail_arg"] = [](names a) {return convert (move (a[0]));}; + f["fail"] += []() {fail << "failed" << endf;}; + f["fail_arg"] += [](names a) {return convert (move (a[0]));}; - f["nullable"] = [](names* a) {return a == nullptr;}; - f["optional"] = [](optional a) {return !a;}; + f["nullable"] += [](names* a) {return a == nullptr;}; + f["optional"] += [](optional 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) {return a;}; - f["ambig"] = [](names a, optional) {return a;}; + f["ambig"] += [](names a, optional) {return a;}; + f["ambig"] += [](names a, optional) {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 +95,7 @@ namespace build2 // Dump arguments. // - functions.insert ( - "dump", + functions.insert ("dump", true).insert ( function_overload ( nullptr, 0, -- cgit v1.1