aboutsummaryrefslogtreecommitdiff
path: root/unit-tests/function
diff options
context:
space:
mode:
Diffstat (limited to 'unit-tests/function')
-rw-r--r--unit-tests/function/buildfile6
-rw-r--r--unit-tests/function/call.testscript161
-rw-r--r--unit-tests/function/driver.cxx131
-rw-r--r--unit-tests/function/syntax.testscript29
4 files changed, 0 insertions, 327 deletions
diff --git a/unit-tests/function/buildfile b/unit-tests/function/buildfile
deleted file mode 100644
index 68dae02..0000000
--- a/unit-tests/function/buildfile
+++ /dev/null
@@ -1,6 +0,0 @@
-# file : unit-tests/function/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/function/call.testscript b/unit-tests/function/call.testscript
deleted file mode 100644
index 36234a1..0000000
--- a/unit-tests/function/call.testscript
+++ /dev/null
@@ -1,161 +0,0 @@
-# file : unit-tests/function/call.testscript
-# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
-# license : MIT; see accompanying LICENSE file
-
-: qual-implicit
-:
-$* <'print $dummy.dummy0()' >'abc'
-
-: qual-explicit
-:
-$* <'print $dummy.qual()' >'abc'
-
-: qual-fail
-:
-$* <'print $qual()' 2>>EOE != 0
-buildfile:1:8: error: unmatched call to qual()
- info: candidate: dummy.qual()
-EOE
-
-: derived-base
-: Test derived-to-base overload resolution
-:
-$* <'print $dummy.abs([dir_path] .)' >'false';
-$* <'print $dummy.abs([abs_dir_path] .)' >'true'
-
-: variadic
-:
-$* <'print $variadic([bool] true, foo, bar)' >'3'
-
-: fail
-:
-$* <'$fail()' 2>>EOE != 0
-error: failed
-buildfile:1:2: info: while calling fail()
-EOE
-
-: fail-invalid-arg
-:
-$* <'$fail_arg(abc)' 2>>EOE != 0
-error: invalid argument: invalid uint64 value: 'abc'
-buildfile:1:2: info: while calling fail_arg(<untyped>)
-EOE
-
-: no-match-name
-:
-$* <'$bogus()' 2>>EOE != 0
-buildfile:1:2: error: unmatched call to bogus()
-EOE
-
-: no-match-count
-:
-$* <'$dummy0(abc)' 2>>EOE != 0
-buildfile:1:2: error: unmatched call to dummy0(<untyped>)
- info: candidate: dummy0(), qualified name dummy.dummy0
-EOE
-
-: no-match-type
-:
-$* <'$dummy1([uint64] 123)' 2>>EOE != 0
-buildfile:1:2: error: unmatched call to dummy1(uint64)
- info: candidate: dummy1(string), qualified name dummy.dummy1
-EOE
-
-: ambig
-:
-$* <'$ambig(abc)' 2>>~/EOE/ != 0
-buildfile:1:2: error: ambiguous call to ambig(<untyped>)
-/((
- info: candidate: ambig(<untyped> [, uint64]), qualified name dummy.ambig
- info: candidate: ambig(<untyped> [, string]), qualified name dummy.ambig
-/)|(
- info: candidate: ambig(<untyped> [, string]), qualified name dummy.ambig
- info: candidate: ambig(<untyped> [, uint64]), qualified name dummy.ambig
-/))
-EOE
-
-: unmatched
-:
-$* <'$ambig(abc, def)' 2>>~/EOE/ != 0
-buildfile:1:2: error: unmatched call to ambig(<untyped>, <untyped>)
-/((
- info: candidate: ambig(<untyped> [, uint64]), qualified name dummy.ambig
- info: candidate: ambig(<untyped> [, string]), qualified name dummy.ambig
-/)|(
- info: candidate: ambig(<untyped> [, string]), qualified name dummy.ambig
- info: candidate: ambig(<untyped> [, uint64]), qualified name dummy.ambig
-/))
-EOE
-
-: reverse
-:
-$* <'print $reverse([string] abc)' >'abc'
-
-: optional-absent
-:
-$* <'print $optional()' >'true'
-
-: optional-present
-:
-$* <'print $optional(abc)' >'false'
-
-: null-true
-:
-$* <'print $nullable([null])' >'true'
-
-: null-false
-:
-$* <'print $nullable(nonull)' >'false'
-
-: null-fail
-:
-$* <'$dummy1([string null])' 2>>EOE != 0
-error: invalid argument: null value
-buildfile:1:2: info: while calling dummy1(string)
-EOE
-
-: print-call-1-untyped
-:
-$* <'$bogus(abc)' 2>>EOE != 0
-buildfile:1:2: error: unmatched call to bogus(<untyped>)
-EOE
-
-: print-call-1-typed
-:
-$* <'$bogus([uint64] 123)' 2>>EOE != 0
-buildfile:1:2: error: unmatched call to bogus(uint64)
-EOE
-
-: print-call-2
-:
-$* <'$bogus(abc, [uint64] 123)' 2>>EOE != 0
-buildfile:1:2: error: unmatched call to bogus(<untyped>, uint64)
-EOE
-
-: print-fovl
-:
-$* <'$ambig([bool] true)' 2>>~/EOE/ != 0
-buildfile:1:2: error: ambiguous call to ambig(bool)
-/((
- info: candidate: ambig(<untyped> [, uint64]), qualified name dummy.ambig
- info: candidate: ambig(<untyped> [, string]), qualified name dummy.ambig
-/)|(
- info: candidate: ambig(<untyped> [, string]), qualified name dummy.ambig
- info: candidate: ambig(<untyped> [, uint64]), qualified name dummy.ambig
-/))
-EOE
-
-: print-fovl-variadic
-:
-$* <'$variadic(abc)' 2>>EOE != 0
-buildfile:1:2: error: unmatched call to variadic(<untyped>)
- info: candidate: variadic(bool [, ...])
-EOE
-
-: member-function
-:
-$* <'print $dummy.length([path] abc)' >'3'
-
-: data-member
-:
-$* <'print $dummy.type([name] cxx{foo})' >'cxx'
diff --git a/unit-tests/function/driver.cxx b/unit-tests/function/driver.cxx
deleted file mode 100644
index 0e128e7..0000000
--- a/unit-tests/function/driver.cxx
+++ /dev/null
@@ -1,131 +0,0 @@
-// file : unit-tests/function/driver.cxx -*- C++ -*-
-// copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
-// license : MIT; see accompanying LICENSE file
-
-#include <iostream>
-
-#include <build2/types.hxx>
-#include <build2/utility.hxx>
-
-#include <build2/parser.hxx>
-#include <build2/context.hxx>
-#include <build2/function.hxx>
-#include <build2/variable.hxx>
-#include <build2/diagnostics.hxx>
-
-using namespace std;
-
-namespace build2
-{
- static const optional<const value_type*> arg_bool[1] =
- {
- &value_traits<bool>::value_type
- };
-
- static dir_path
- scoped (const scope*, dir_path d)
- {
- return d;
- }
-
- static void
- scoped_void (const scope*, dir_path)
- {
- }
-
- int
- main (int, char* argv[])
- {
- init (argv[0], 1); // Fake build system driver, default verbosity.
- reset (strings ()); // No command line variables.
-
- function_family f ("dummy");
-
- 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["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["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[".qual"] = []() {return "abc";};
-
- f[".length"] = &path::size; // Member function.
- f[".type"] = &name::type; // Data member.
-
- 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",
- function_overload (
- nullptr,
- 1,
- function_overload::arg_variadic,
- function_overload::types (arg_bool, 1),
- [] (const scope*, vector_view<value> args, const function_overload&)
- {
- return value (static_cast<uint64_t> (args.size ()));
- }));
-
- // Dump arguments.
- //
- functions.insert (
- "dump",
- function_overload (
- nullptr,
- 0,
- function_overload::arg_variadic,
- function_overload::types (),
- [] (const scope*, vector_view<value> args, const function_overload&)
- {
- for (value& a: args)
- {
- if (a.null)
- cout << "[null]";
- else if (!a.empty ())
- {
- names storage;
- cout << reverse (a, storage);
- }
- cout << endl;
- }
- return value (nullptr);
- }));
-
- try
- {
- scope& s (*scope::global_);
-
- parser p;
- p.parse_buildfile (cin, path ("buildfile"), s, s);
- }
- catch (const failed&)
- {
- return 1;
- }
-
- return 0;
- }
-}
-
-int
-main (int argc, char* argv[])
-{
- return build2::main (argc, argv);
-}
diff --git a/unit-tests/function/syntax.testscript b/unit-tests/function/syntax.testscript
deleted file mode 100644
index 6af5f7e..0000000
--- a/unit-tests/function/syntax.testscript
+++ /dev/null
@@ -1,29 +0,0 @@
-# file : unit-tests/function/syntax.testscript
-# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
-# license : MIT; see accompanying LICENSE file
-
-$* <'$dump()' >:'' : none
-$* <'$dump( )' >:'' : none-in-spaces
-$* <'$dump("")' >'{}' : one-empty
-$* <'$dump(a)' >'a' : one-single
-$* <'$dump(a b c)' >'a b c' : one-list
-$* <'$dump(d/t{x y z})' >'d/t{x} d/t{y} d/t{z}' : one-names
-
-$* <'print a$dummy1([string] b)c' >'abc' : concat
-$* <'print $dummy2([uint64] 123, [uint64] 321)' >'444' : multi-arg
-
-: quoting
-: Verify we can inhibit function call with quoting
-:
-$* <<EOI >>EOO
-foo = FOO
-bar = BAR
-
-print $foo"($bar)"
-print "$foo"($bar)
-print "$foo""($bar)"
-EOI
-FOOBAR
-FOOBAR
-FOOBAR
-EOO