Skip to content

Commit

Permalink
Test interaction of subset field type ascription with type promotion …
Browse files Browse the repository at this point in the history
…+ options.
  • Loading branch information
mfp committed Oct 10, 2017
1 parent 6ef4840 commit d504f9a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/test_subsets.ml
Expand Up @@ -123,6 +123,20 @@ let tests = "subsets" >::: [
}
{ Subset__h3.b = { Subset__h1.c = "bar" } }
end;

"type promotion after field type ascription" >:: begin fun () ->
check_roundtrip
Subset__i1.pp Subset__i.write Subset__i1.read
{ Subset__i.a = "foo"; b = 42 }
{ Subset__i1.b = 42. }
end;

"type options after field type ascription" >:: begin fun () ->
check_roundtrip
Subset__j2.pp Subset__j1.write Subset__j2.read
{ Subset__j1.a = Opt2.A 42; b = Opt2.A "foo" }
{ Subset__j2.b = Some "foo" }
end;
]

let () = Register_test.register "subsets"
Expand Down
8 changes: 8 additions & 0 deletions test/test_types.proto
Expand Up @@ -150,4 +150,12 @@ message subset__h1 = {| subset__h with c |}
message subset__h2 = subset__h0<subset__h, subset__h, string>
message subset__h3 = {| subset__h2 with b : subset__h1 |}

message subset__i = { a : string; b : int }
message subset__i1 = {| subset__i with b : float |}

type opt 'a = None | Some 'a options "ocaml.type_equals" = "option"
type opt2 'a = B | A 'a
message subset__j1 = { a : opt2<int>; b : opt2<string> }
message subset__j2 = {| subset__j1 with b : opt<string> |}

(* vim:set ft=ocaml: *)

0 comments on commit d504f9a

Please sign in to comment.