From f5332b2c7bbf6128de5f2467560e808d8d8d41f3 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Thu, 26 Dec 2024 21:22:23 +0100 Subject: Added a cmp function --- tests/expression_builder.ml | 1 + tests/expression_query.ml | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) (limited to 'tests') 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 -- cgit v1.2.3