unit test infrastructure for optimization

This commit is contained in:
adelaett 2023-03-17 17:19:50 +01:00
parent 850a1fdb56
commit 61ad00f277
3 changed files with 25 additions and 3 deletions

View File

@ -4,11 +4,9 @@
, benchmark
, bindlib
, buildDunePackage
, calendar
, cmdliner
, cppo
, dates_calc
, fetchFromGitHub
, js_of_ocaml
, js_of_ocaml-ppx
, menhir
@ -26,6 +24,7 @@
, zarith
, zarith_stubs_js
, cohttp-lwt-unix
, ppx_expect
}:
buildDunePackage {
@ -63,6 +62,7 @@ buildDunePackage {
zarith
zarith_stubs_js
cohttp-lwt-unix
ppx_expect
];
# Currently there is no unit tests in catala and Cram tests are handled by clerk

View File

@ -2,8 +2,9 @@
(name lcalc)
(public_name catala.lcalc)
(libraries bindlib ubase dcalc scopelang catala.runtime_ocaml)
(inline_tests)
(preprocess
(pps visitors.ppx)))
(pps visitors.ppx ppx_expect)))
(documentation
(package catala)

View File

@ -222,3 +222,24 @@ let optimize_program (p : 'm program) : untyped program =
(* _beta_optimizations; *)
peephole_optimizations;
])
let%expect_test _ =
Cli.call_unstyled (fun _ ->
let x = Var.make "x" in
let t = EnumName.fresh ("t", Pos.no_pos) in
let a = EnumConstructor.fresh ("A", Pos.no_pos) in
let b = EnumConstructor.fresh ("B", Pos.no_pos) in
let nomark = Untyped { pos = Pos.no_pos } in
let e1 = Expr.einj (Expr.evar x nomark) a t nomark in
let e2 = Expr.einj (Expr.evar x nomark) b t nomark in
Format.printf "e1=%a\n" (Print.expr_debug ~debug:false) (Expr.unbox e1);
Format.printf "e2=%a\n" (Print.expr_debug ~debug:false) (Expr.unbox e2);
[%expect {|
e1=A (x)
e2=B
(x) |}])