aboutsummaryrefslogtreecommitdiff
path: root/unit-tests
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-12-05 15:09:04 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-12-05 15:09:04 +0200
commit54870fb76b5f59cc2e6d69a8c7a8ef17853a0029 (patch)
tree770b01aa56348ec75f17fb834a2a7123ba9c3f73 /unit-tests
parentef7cb7ea3e6fcb21a4fcf38602b3f43f03232ace (diff)
Add comma, ternary, logical operators support in eval context
Diffstat (limited to 'unit-tests')
-rw-r--r--unit-tests/function/call.test3
-rw-r--r--unit-tests/function/driver.cxx1
-rw-r--r--unit-tests/function/syntax.test2
-rw-r--r--unit-tests/lexer/buildfile2
-rw-r--r--unit-tests/lexer/eval.test76
5 files changed, 81 insertions, 3 deletions
diff --git a/unit-tests/function/call.test b/unit-tests/function/call.test
index d16b91c..9129785 100644
--- a/unit-tests/function/call.test
+++ b/unit-tests/function/call.test
@@ -25,8 +25,7 @@ $* <'print $dummy.abs([abs_dir_path] .)' >'true'
: variadic
:
-# @@ TMP: add some args
-$* <'print $variadic([bool] true)' >'1'
+$* <'print $variadic([bool] true, foo, bar)' >'3'
: fail
:
diff --git a/unit-tests/function/driver.cxx b/unit-tests/function/driver.cxx
index 3dea374..235af0c 100644
--- a/unit-tests/function/driver.cxx
+++ b/unit-tests/function/driver.cxx
@@ -38,6 +38,7 @@ namespace build2
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;};
diff --git a/unit-tests/function/syntax.test b/unit-tests/function/syntax.test
index d644fd1..11ff3c1 100644
--- a/unit-tests/function/syntax.test
+++ b/unit-tests/function/syntax.test
@@ -12,6 +12,8 @@ $* <'$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
:
diff --git a/unit-tests/lexer/buildfile b/unit-tests/lexer/buildfile
index d9bd2df..bdd8dd1 100644
--- a/unit-tests/lexer/buildfile
+++ b/unit-tests/lexer/buildfile
@@ -8,6 +8,6 @@ import libs = libbutl%lib{butl}
src = token lexer diagnostics utility variable name b-options types-parsers
exe{driver}: cxx{driver} ../../build2/cxx{$src} $libs \
-test{comment quoting}
+test{comment eval quoting}
include ../../build2/
diff --git a/unit-tests/lexer/eval.test b/unit-tests/lexer/eval.test
new file mode 100644
index 0000000..0f4f79b
--- /dev/null
+++ b/unit-tests/lexer/eval.test
@@ -0,0 +1,76 @@
+# file : unit-tests/lexer/eval.test
+# copyright : Copyright (c) 2014-2016 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+test.arguments = eval
+
+: punctuation
+:
+$* <:'x:x{x}x[x]x$x?x,x(x)' >>EOO
+'x'
+:
+'x'
+{
+'x'
+}
+'x'
+[
+'x'
+]
+'x'
+$
+'x'
+?
+'x'
+,
+'x'
+(
+'x'
+)
+EOO
+
+: logical
+:
+$* <:'x|x||x&x&&x!x!!x)' >>EOO
+'x|x'
+||
+'x&x'
+&&
+'x'
+!
+'x'
+!
+!
+'x'
+)
+EOO
+
+: comparison
+:
+$* <:'x=x==x!=x<x<=x>x>=)' >>EOO
+'x=x'
+==
+'x'
+!=
+'x'
+<
+'x'
+<=
+'x'
+>
+'x'
+>=
+)
+EOO
+
+: newline
+:
+$* <'x' >- 2>>EOE != 0
+stdin:1:2: error: newline in evaluation context
+EOE
+
+: eof
+:
+$* <:'' 2>>EOE != 0
+stdin:1:1: error: unterminated evaluation context
+EOE