aboutsummaryrefslogtreecommitdiff
path: root/tests/odf
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2018-01-31 13:20:20 +0100
committerSébastien Dailly <sebastien@chimrod.com>2018-02-07 13:42:36 +0100
commit824f2987d47e87d58ee2a4a96d7be417aad6aeab (patch)
treebfbaca8d1c13a2eb1e5568f363cdcd6c94f1786f /tests/odf
parent112ab4b1c396fc2117191297227d8e411f9b9bb3 (diff)
API refactoring : made the GADT abstract, provide contructor for each case, and deported the
expression with evaluation with module functors
Diffstat (limited to 'tests/odf')
-rwxr-xr-xtests/odf/odf_ExpressionParser_test.ml54
1 files changed, 28 insertions, 26 deletions
diff --git a/tests/odf/odf_ExpressionParser_test.ml b/tests/odf/odf_ExpressionParser_test.ml
index 18efe96..3d6c4fa 100755
--- a/tests/odf/odf_ExpressionParser_test.ml
+++ b/tests/odf/odf_ExpressionParser_test.ml
@@ -2,11 +2,13 @@ open OUnit2
let u = UTF8.from_utf8string
-let _msg ~(expected:ScTypes.expression) ~(result:ScTypes.expression) =
+module Show = ScTypes.Expr.Eval(Show_expr.Show_Expr(Show_ref)(Show_type))
+
+let _msg ~(expected:ScTypes.Expr.t) ~(result:ScTypes.Expr.t) =
let b1 = UTF8.Buffer.create 16
and b2 = UTF8.Buffer.create 16 in
- ScTypes.show_expr b1 expected;
- ScTypes.show_expr b2 result;
+ Show.eval expected () b1;
+ Show.eval result () b2;
Printf.sprintf "Expected \n\t%s but got \n\t%s"
(UTF8.raw_encode @@ UTF8.Buffer.contents b1)
@@ -14,7 +16,7 @@ let _msg ~(expected:ScTypes.expression) ~(result:ScTypes.expression) =
-let build_num value = ScTypes.number (
+let build_num value = ScTypes.Type.number (
DataType.Num.of_int value
)
@@ -28,22 +30,22 @@ let test_formula ctx = begin
let expected = ScTypes.(
- Call(u"CONCATENATE", [
- Call (u"SUM", [
- Ref (Range (((6, 16), (false, false)), (((36, 16), (false, false)))))]);
- Value (string (u"/"));
- Call(u"*", [
- Value (build_num 8);
- Call(u"NETWORKDAYS", [
- Ref (Cell ((6, 6), (false, false)));
- Call(u"+", [
- Ref (Cell ((6, 6), (false, false)));
- Expression (
- Call( u"-", [
- Call(u"ORG.OPENOFFICE.DAYSINMONTH", [
- Ref (Cell ((6, 6), (false, false)))]);
- Value (build_num 1);
- ]))])])])])) in
+ Expr.call3 (u"CONCATENATE")
+ (Expr.call1 (u"SUM")
+ (Expr.ref (Refs.range ((6, 16), (false, false)) (((36, 16), (false, false))))))
+ (Expr.value (Type.string (u"/")))
+ (Expr.call2 (u"*")
+ (Expr.value (build_num 8))
+ (Expr.call2 (u"NETWORKDAYS")
+ (Expr.ref (Refs.cell ((6, 6), (false, false))))
+ (Expr.call2 (u"+")
+ (Expr.ref (Refs.cell ((6, 6), (false, false))))
+ (Expr.expression
+ (Expr.call2 (u"-")
+ (Expr.call1 (u"ORG.OPENOFFICE.DAYSINMONTH")
+ (Expr.ref (Refs.cell ((6, 6), (false, false)))))
+ (Expr.value (build_num 1));
+ )))))) in
assert_equal
~msg:(_msg ~expected ~result)
@@ -59,11 +61,11 @@ let test_formula2 ctx = begin
let expected = ScTypes.(
- Call (u"+", [
- Call(u"*", [
- Ref (Cell ((8, 51), (false, false)));
- Ref (Cell ((7, 52), (false, false)))
- ])])) in
+ Expr.call1 (u"+")
+ (Expr.call2 (u"*")
+ (Expr.ref (Refs.cell ((8, 51), (false, false))))
+ (Expr.ref (Refs.cell ((7, 52), (false, false))))
+ )) in
assert_equal
~msg:(_msg ~expected ~result)
@@ -72,7 +74,7 @@ let test_formula2 ctx = begin
end
-let tests = "odf_ExpressionParser_test">::: [
+let tests = "odf_ExpressionParser_test" >::: [
"test_formula" >:: test_formula;
"test_formula2" >:: test_formula2;