Skip to content

Commit

Permalink
Enhance ExpToSegment tests with constructor and match statement cases
Browse files Browse the repository at this point in the history
  • Loading branch information
7h3kk1d committed Dec 20, 2024
1 parent 0bba4b1 commit 54e19f4
Showing 1 changed file with 50 additions and 6 deletions.
56 changes: 50 additions & 6 deletions test/Test_ExpToSegment.re
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
open Alcotest;
open Haz3lcore;

let segmentize =
ExpToSegment.exp_to_segment(
~settings=ExpToSegment.Settings.of_core(~inline=true, CoreSettings.off),
_,
);

let tests = (
"ExpToSegment",
[
test_case(
"Empty Ids on ExpToSegment does not throw",
"Empty Ids on ExpToSegment constructor",
`Quick,
() => {
let _ =
ExpToSegment.exp_to_segment(
~settings=
ExpToSegment.Settings.of_core(~inline=true, CoreSettings.off),
let segment =
segmentize(
Let(
Cast(
ListLit([]) |> Pat.fresh,
Expand All @@ -24,7 +28,47 @@ let tests = (
)
|> Exp.fresh,
);
();
let serialized = Printer.of_segment(~holes=Some("?"), segment);

check(
string,
"ascribed sum type constructor in pattern",
serialized,
"let []: (+ Jg) = ? in ?",
);
},
),
test_case(
"Match statement",
`Quick,
() => {
let segment =
segmentize(
Match(
Var("x") |> Exp.fresh,
[
(
Constructor("A", Unknown(Internal) |> Typ.fresh)
|> Pat.fresh,
Int(1) |> Exp.fresh,
),
(
Constructor("B", Unknown(Internal) |> Typ.fresh)
|> Pat.fresh,
Int(2) |> Exp.fresh,
),
],
)
|> Exp.fresh,
);
let serialized = Printer.of_segment(~holes=Some("?"), segment);

check(
string,
"Match statement",
serialized,
"case x end" // TODO Why is this not serializing the cases
);
},
),
],
Expand Down

0 comments on commit 54e19f4

Please sign in to comment.