From de85c69e1ce5fe9452a6d217644de5d6eea1713a Mon Sep 17 00:00:00 2001 From: Alexander Bandukwala <7h3kk1d@gmail.com> Date: Sun, 13 Oct 2024 21:05:32 -0400 Subject: [PATCH] Tests for multiple labels --- test/Test_MakeTerm.re | 34 ++++++++++++++++++++++++++++++++++ test/Test_Statics.re | 22 ++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/test/Test_MakeTerm.re b/test/Test_MakeTerm.re index 13894ee3b..d5e8bc9a7 100644 --- a/test/Test_MakeTerm.re +++ b/test/Test_MakeTerm.re @@ -73,4 +73,38 @@ let tests = [ let y : (l=Int) = x in y", ) }), + test_case("Multiple labels in tuple", `Quick, () => { + exp_check( + Let( + Cast( + Var("x") |> Pat.fresh, + Parens( + Prod([ + TupLabel(Label("l") |> Typ.fresh, Int |> Typ.fresh) + |> Typ.fresh, + TupLabel(Label("l2") |> Typ.fresh, String |> Typ.fresh) + |> Typ.fresh, + ]) + |> Typ.fresh, + ) + |> Typ.fresh, + Unknown(Internal) |> Typ.fresh, + ) + |> Pat.fresh, + Parens( + Tuple([ + TupLabel(Label("l") |> Exp.fresh, Int(32) |> Exp.fresh) + |> Exp.fresh, + TupLabel(Label("l2") |> Exp.fresh, String("") |> Exp.fresh) + |> Exp.fresh, + ]) + |> Exp.fresh, + ) + |> Exp.fresh, + Var("x") |> Exp.fresh, + ) + |> Exp.fresh, + {|let x : (l=Int, l2=String) = (l=32, l2="") in x|}, + ) + }), ]; diff --git a/test/Test_Statics.re b/test/Test_Statics.re index 4734ff342..e85718e79 100644 --- a/test/Test_Statics.re +++ b/test/Test_Statics.re @@ -370,4 +370,26 @@ let tests = ) |> Exp.fresh, ), + fully_consistent_typecheck( + "Labeled tuple with multiple labels", + {|(l=32, l2="")|}, + Some( + Prod([ + TupLabel(Label("l") |> Typ.fresh, Int |> Typ.fresh) |> Typ.fresh, + TupLabel(Label("l2") |> Typ.fresh, String |> Typ.fresh) + |> Typ.fresh, + ]) + |> Typ.fresh, + ), + Parens( + Tuple([ + TupLabel(Label("l") |> Exp.fresh, Int(32) |> Exp.fresh) + |> Exp.fresh, + TupLabel(Label("l2") |> Exp.fresh, String("") |> Exp.fresh) + |> Exp.fresh, + ]) + |> Exp.fresh, + ) + |> Exp.fresh, + ), ];