mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
unit test infrastructure for optimization
This commit is contained in:
parent
850a1fdb56
commit
61ad00f277
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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) |}])
|
||||
|
Loading…
Reference in New Issue
Block a user