arkdro avatar arkdro committed 59d67f2

do ocaml calculation if configured

Comments (0)

Files changed (2)

erlang/test/num_SUITE.erl

     end.
 
 do_op(divide, D1, D2) ->
-    Res1 = c_server:divide(D1, D2),
+    Res1 = call_ocaml(divide, D1, D2),
     Res2 = decimal:divide(D1, D2, ?d_context),
     {Res1, Res2};
 do_op(subtract, D1, D2) ->
-    Res1 = c_server:subtract(D1, D2),
+    Res1 = call_ocaml(subtract, D1, D2),
     Res2 = decimal:subtract(D1, D2, ?d_context),
     {Res1, Res2};
 do_op(add, D1, D2) ->
-    Res1 = c_server:add(D1, D2),
+    Res1 = call_ocaml(add, D1, D2),
     Res2 = decimal:add(D1, D2, ?d_context),
     {Res1, Res2};
 do_op(multiply, D1, D2) ->
-    Res1 = c_server:multiply(D1, D2),
+    Res1 = call_ocaml(multiply, D1, D2),
     Res2 = decimal:multiply(D1, D2, ?d_context),
     {Res1, Res2}.
 
+call_ocaml(Op, D1, D2) ->
+    Flag = ct:get_config(do_ocaml_calc, true),
+    call_ocaml(Flag, Op, D1, D2).
+
+call_ocaml(false, _, _D1, _D2) ->
+    no_ocaml_calc_configured;
+call_ocaml(true, divide, D1, D2) ->
+    c_server:divide(D1, D2);
+call_ocaml(true, subtract, D1, D2) ->
+    c_server:subtract(D1, D2);
+call_ocaml(true, add, D1, D2) ->
+    c_server:add(D1, D2);
+call_ocaml(true, multiply, D1, D2) ->
+    c_server:multiply(D1, D2).
+
 compare(R1, R2) ->
     Do_compare = ct:get_config(do_compare, true),
     do_compare(Do_compare, {ok, R1}, R1).

erlang/test/test.config

 {mantissa_max, 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999}.
 
 {do_compare, true}.
+{do_ocaml_calc, true}.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.