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
|
, benchmark
|
||||||
, bindlib
|
, bindlib
|
||||||
, buildDunePackage
|
, buildDunePackage
|
||||||
, calendar
|
|
||||||
, cmdliner
|
, cmdliner
|
||||||
, cppo
|
, cppo
|
||||||
, dates_calc
|
, dates_calc
|
||||||
, fetchFromGitHub
|
|
||||||
, js_of_ocaml
|
, js_of_ocaml
|
||||||
, js_of_ocaml-ppx
|
, js_of_ocaml-ppx
|
||||||
, menhir
|
, menhir
|
||||||
@ -26,6 +24,7 @@
|
|||||||
, zarith
|
, zarith
|
||||||
, zarith_stubs_js
|
, zarith_stubs_js
|
||||||
, cohttp-lwt-unix
|
, cohttp-lwt-unix
|
||||||
|
, ppx_expect
|
||||||
}:
|
}:
|
||||||
|
|
||||||
buildDunePackage {
|
buildDunePackage {
|
||||||
@ -63,6 +62,7 @@ buildDunePackage {
|
|||||||
zarith
|
zarith
|
||||||
zarith_stubs_js
|
zarith_stubs_js
|
||||||
cohttp-lwt-unix
|
cohttp-lwt-unix
|
||||||
|
ppx_expect
|
||||||
];
|
];
|
||||||
|
|
||||||
# Currently there is no unit tests in catala and Cram tests are handled by clerk
|
# Currently there is no unit tests in catala and Cram tests are handled by clerk
|
||||||
|
@ -2,8 +2,9 @@
|
|||||||
(name lcalc)
|
(name lcalc)
|
||||||
(public_name catala.lcalc)
|
(public_name catala.lcalc)
|
||||||
(libraries bindlib ubase dcalc scopelang catala.runtime_ocaml)
|
(libraries bindlib ubase dcalc scopelang catala.runtime_ocaml)
|
||||||
|
(inline_tests)
|
||||||
(preprocess
|
(preprocess
|
||||||
(pps visitors.ppx)))
|
(pps visitors.ppx ppx_expect)))
|
||||||
|
|
||||||
(documentation
|
(documentation
|
||||||
(package catala)
|
(package catala)
|
||||||
|
@ -222,3 +222,24 @@ let optimize_program (p : 'm program) : untyped program =
|
|||||||
(* _beta_optimizations; *)
|
(* _beta_optimizations; *)
|
||||||
peephole_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