aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2024-12-26 21:22:23 +0100
committerSébastien Dailly <sebastien@dailly.me>2024-12-26 21:22:23 +0100
commitf5332b2c7bbf6128de5f2467560e808d8d8d41f3 (patch)
tree525e5f94604d30dff69469d9b88daadb202ea8ad /tests
parent39f39919fb4749787393e95503f9814912265a73 (diff)
Added a cmp function
Diffstat (limited to 'tests')
-rw-r--r--tests/expression_builder.ml1
-rw-r--r--tests/expression_query.ml18
2 files changed, 19 insertions, 0 deletions
diff --git a/tests/expression_builder.ml b/tests/expression_builder.ml
index fd9a17f..6fffc67 100644
--- a/tests/expression_builder.ml
+++ b/tests/expression_builder.ml
@@ -6,6 +6,7 @@ let literal_test : 'a T.t = T.Literal "test"
let literal_quoted : 'a T.t = T.Literal "'"
let literal_zero : 'a T.t = T.Literal "0"
let integer_zero : 'a T.t = T.Integer "0"
+let integer_neg_one : 'a T.t = T.Integer "-1"
let integer_one : 'a T.t = T.Integer "1"
let concat : 'a T.t = T.Concat [ T.Empty; T.Literal "test" ]
let expr : 'a T.t = T.Function ("expr", [ literal_test; T.Literal "NOT NULL" ])
diff --git a/tests/expression_query.ml b/tests/expression_query.ml
index d260a76..e2abc43 100644
--- a/tests/expression_query.ml
+++ b/tests/expression_query.ml
@@ -180,6 +180,23 @@ let counter_order =
assert_equal ~printer expected content
+let cmp =
+ "cmp" >:: fun _ ->
+ let expr =
+ eval
+ @@ Expr.(
+ function' T.Cmp
+ [
+ Expr.integer_zero;
+ Expr.integer_one;
+ Expr.integer_neg_one;
+ Expr.integer_zero;
+ Expr.integer_one;
+ ])
+ in
+ let content = test_expr expr and expected = "IIF(0=1, 0, IIF(0>1, 1, -1))" in
+ assert_equal ~printer expected content
+
let test_suit =
[
empty;
@@ -203,6 +220,7 @@ let test_suit =
max;
counter_no_order;
counter_order;
+ cmp;
]
let tests = "expression_query" >::: test_suit