diff --git a/test/Test_ExpToSegment.re b/test/Test_ExpToSegment.re index e365ab7ceb..505cfc281f 100644 --- a/test/Test_ExpToSegment.re +++ b/test/Test_ExpToSegment.re @@ -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, @@ -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 + ); }, ), ],