aboutsummaryrefslogtreecommitdiffstats
path: root/eval
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@oath.com>2021-08-31 10:36:05 +0000
committerHåvard Pettersen <havardpe@oath.com>2021-08-31 10:36:05 +0000
commit220a9d181b85cb4c28148b45d485ee049ff1b8f0 (patch)
tree71c13e4bdc213f11d9a176eaf18c0e2a749151df /eval
parent5b4b8cfc34e7a61971ef43d707446d16ff101d03 (diff)
minor fixes after review
Diffstat (limited to 'eval')
-rw-r--r--eval/src/apps/eval_expr/eval_expr.cpp9
-rw-r--r--eval/src/tests/apps/eval_expr/eval_expr_test.cpp27
2 files changed, 20 insertions, 16 deletions
diff --git a/eval/src/apps/eval_expr/eval_expr.cpp b/eval/src/apps/eval_expr/eval_expr.cpp
index a5dd5368d28..67eda68937a 100644
--- a/eval/src/apps/eval_expr/eval_expr.cpp
+++ b/eval/src/apps/eval_expr/eval_expr.cpp
@@ -27,7 +27,6 @@ using vespalib::slime::JsonFormat;
using vespalib::slime::Inspector;
using vespalib::slime::Cursor;
-
const auto &factory = FastValueBuilderFactory::get();
int usage(const char *self) {
@@ -39,7 +38,8 @@ int usage(const char *self) {
fprintf(stderr, " using single letter symbols ('a' through 'z'). Quote expressions to\n");
fprintf(stderr, " make sure they become separate parameters. The --verbose option may\n");
fprintf(stderr, " be specified to get more detailed informaion about how the various\n");
- fprintf(stderr, " expressions are optimized.\n\n");
+ fprintf(stderr, " expressions are optimized.\n");
+ fprintf(stderr, "\n");
fprintf(stderr, "example: %s \"2+2\" \"a+2\" \"a+b\"\n", self);
fprintf(stderr, " (a=4, b=6, c=10)\n");
fprintf(stderr, "\n");
@@ -62,12 +62,13 @@ int usage(const char *self) {
fprintf(stderr, " relevant command and will result in the 'steps' field being populated in\n");
fprintf(stderr, " the response.\n");
fprintf(stderr, " if any command fails, the response will be { error:string }\n");
+ fprintf(stderr, " commands may be batched using json arrays:\n");
+ fprintf(stderr, " [cmd1,cmd2,cmd3] -> [res1,res2,res3]\n");
fprintf(stderr, "\n");
// -------------------------------------------------------------------------------
return 1;
}
-
int overflow(int cnt, int max) {
fprintf(stderr, "error: too many expressions: %d (max is %d)\n", cnt, max);
return 2;
@@ -221,7 +222,7 @@ int interactive_mode(Context &ctx) {
if (is_only_whitespace(line)) {
continue;
}
- if (line.find(exit_cmd) == 0) {
+ if (line == exit_cmd) {
return 0;
}
if (line.find(verbose_cmd) == 0) {
diff --git a/eval/src/tests/apps/eval_expr/eval_expr_test.cpp b/eval/src/tests/apps/eval_expr/eval_expr_test.cpp
index 8e0b3286421..bcbaf1c7d20 100644
--- a/eval/src/tests/apps/eval_expr/eval_expr_test.cpp
+++ b/eval/src/tests/apps/eval_expr/eval_expr_test.cpp
@@ -17,7 +17,7 @@ using vespalib::slime::Inspector;
vespalib::string module_build_path("../../../../");
vespalib::string binary = module_build_path + "src/apps/eval_expr/vespa-eval-expr";
-vespalib::string server_cmd = binary + " --verbose json-repl";
+vespalib::string server_cmd = binary + " json-repl";
//-----------------------------------------------------------------------------
@@ -32,13 +32,12 @@ void read_until_eof(Input &input) {
// It seems that linking with the eval library contaminates the
// process proxy in such a way that valgrind will fail. The working
// theory is that some static state gets initialized before the proxy
-// is forked. This state conflicts with itself when the eval library
-// is loaded again when doing exec on vespa-eval-expr. This test
-// bypasses the issue by linking with vespalib instead. A more robust
-// solution would be to reverse the roles of the process proxy and the
-// program; letting the proxy start the program. This could also be
-// combined with the ability to send open file descriptors on unix
-// domain sockets to avoid indirection for stdin/stdout streams.
+// is forked. This test bypasses the issue by linking with vespalib
+// instead. A more robust solution would be to reverse the roles of
+// the process proxy and the program; letting the proxy start the
+// program. This could also be combined with the ability to send open
+// file descriptors on unix domain sockets to avoid indirection for
+// stdin/stdout streams.
void write_compact(const Slime &slime, Output &out) {
JsonFormat::encode(slime, out, true);
@@ -251,13 +250,17 @@ TEST_F("require that empty operation batch works", Server()) {
//-----------------------------------------------------------------------------
TEST_F("require that empty expression produces error", Server()) {
- auto res = f1.eval("");
- TEST_DO(res.verify_error("missing expression"));
+ TEST_DO(f1.eval("").verify_error("missing expression"));
}
TEST_F("require that parse error produces error", Server()) {
- auto res = f1.eval("this does not parse");
- TEST_DO(res.verify_error("expression parsing failed"));
+ TEST_DO(f1.eval("this does not parse").verify_error("expression parsing failed"));
+}
+
+TEST_F("require that type issues produces error", Server()) {
+ TEST_DO(f1.eval("tensor(x[3]):[1,2,3]", "a").verify_result("tensor(x[3]):{{x:0}:1,{x:1}:2,{x:2}:3}"));
+ TEST_DO(f1.eval("tensor(x[2]):[4,5]", "b").verify_result("tensor(x[2]):{{x:0}:4,{x:1}:5}"));
+ TEST_DO(f1.eval("a+b").verify_error("type resolving failed"));
}
//-----------------------------------------------------------------------------