Skip to content

Commit 9909598

Browse files
promote test with ocamlformat 0.27.0
1 parent e3023ac commit 9909598

File tree

2 files changed

+117
-106
lines changed

2 files changed

+117
-106
lines changed

ppx/test/ppx_deriving_json_js.t

Lines changed: 84 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@
5252
5353
[@@@ocaml.warning "-39-11-27"]
5454
55-
let rec param_of_json a_of_json : Js.Json.t -> 'a param =
56-
fun x -> a_of_json x
55+
let rec param_of_json a_of_json =
56+
(fun x -> a_of_json x : Js.Json.t -> 'a param)
5757

5858
let _ = param_of_json
5959

6060
[@@@ocaml.warning "-39-11-27"]
6161

62-
let rec param_to_json a_to_json : 'a param -> Js.Json.t =
63-
fun x -> a_to_json x
62+
let rec param_to_json a_to_json =
63+
(fun x -> a_to_json x : 'a param -> Js.Json.t)
6464
6565
let _ = param_to_json
6666
end [@@ocaml.doc "@inline"] [@@merlin.hide]
@@ -684,45 +684,48 @@
684684

685685
[@@@ocaml.warning "-39-11-27"]
686686

687-
let rec c_of_json a_of_json : Js.Json.t -> 'a c =
688-
fun x ->
689-
if Js.Array.isArray x then
690-
let array = (Obj.magic x : Js.Json.t array) in
691-
let len = Js.Array.length array in
692-
if Stdlib.( > ) len 0 then
693-
let tag = Js.Array.unsafe_get array 0 in
694-
if Stdlib.( = ) (Js.typeof tag) "string" then
695-
let tag = (Obj.magic tag : string) in
696-
if Stdlib.( = ) tag "C" then
697-
if Stdlib.( <> ) len 2 then
698-
Ppx_deriving_json_runtime.of_json_msg_error ~json:x
699-
"expected a JSON array of length 2"
700-
else `C (a_of_json (Js.Array.unsafe_get array 1))
701-
else
702-
raise
703-
(Ppx_deriving_json_runtime.Of_json_error
704-
(Ppx_deriving_json_runtime.Unexpected_variant
705-
"unexpected variant"))
706-
else
707-
Ppx_deriving_json_runtime.of_json_error ~json:x
708-
"expected a non empty JSON array with element being a string"
709-
else
710-
Ppx_deriving_json_runtime.of_json_error ~json:x
711-
"expected a non empty JSON array"
712-
else
713-
Ppx_deriving_json_runtime.of_json_error ~json:x
714-
"expected a non empty JSON array"
687+
let rec c_of_json a_of_json =
688+
(fun x ->
689+
if Js.Array.isArray x then
690+
let array = (Obj.magic x : Js.Json.t array) in
691+
let len = Js.Array.length array in
692+
if Stdlib.( > ) len 0 then
693+
let tag = Js.Array.unsafe_get array 0 in
694+
if Stdlib.( = ) (Js.typeof tag) "string" then
695+
let tag = (Obj.magic tag : string) in
696+
if Stdlib.( = ) tag "C" then
697+
if Stdlib.( <> ) len 2 then
698+
Ppx_deriving_json_runtime.of_json_msg_error ~json:x
699+
"expected a JSON array of length 2"
700+
else `C (a_of_json (Js.Array.unsafe_get array 1))
701+
else
702+
raise
703+
(Ppx_deriving_json_runtime.Of_json_error
704+
(Ppx_deriving_json_runtime.Unexpected_variant
705+
"unexpected variant"))
706+
else
707+
Ppx_deriving_json_runtime.of_json_error ~json:x
708+
"expected a non empty JSON array with element being a \
709+
string"
710+
else
711+
Ppx_deriving_json_runtime.of_json_error ~json:x
712+
"expected a non empty JSON array"
713+
else
714+
Ppx_deriving_json_runtime.of_json_error ~json:x
715+
"expected a non empty JSON array"
716+
: Js.Json.t -> 'a c)
715717
716718
let _ = c_of_json
717719
718720
[@@@ocaml.warning "-39-11-27"]
719721
720-
let rec c_to_json a_to_json : 'a c -> Js.Json.t =
721-
fun x ->
722-
match x with
723-
| `C x_0 ->
724-
(Obj.magic [| (Obj.magic "C" : Js.Json.t); a_to_json x_0 |]
725-
: Js.Json.t)
722+
let rec c_to_json a_to_json =
723+
(fun x ->
724+
match x with
725+
| `C x_0 ->
726+
(Obj.magic [| (Obj.magic "C" : Js.Json.t); a_to_json x_0 |]
727+
: Js.Json.t)
728+
: 'a c -> Js.Json.t)
726729

727730
let _ = c_to_json
728731
end [@@ocaml.doc "@inline"] [@@merlin.hide]
@@ -983,51 +986,54 @@
983986

984987
[@@@ocaml.warning "-39-11-27"]
985988

986-
let rec p2_of_json a_of_json b_of_json : Js.Json.t -> ('a, 'b) p2 =
987-
fun x ->
988-
if Js.Array.isArray x then
989-
let array = (Obj.magic x : Js.Json.t array) in
990-
let len = Js.Array.length array in
991-
if Stdlib.( > ) len 0 then
992-
let tag = Js.Array.unsafe_get array 0 in
993-
if Stdlib.( = ) (Js.typeof tag) "string" then
994-
let tag = (Obj.magic tag : string) in
995-
if Stdlib.( = ) tag "A" then
996-
if Stdlib.( <> ) len 2 then
997-
Ppx_deriving_json_runtime.of_json_msg_error ~json:x
998-
"expected a JSON array of length 2"
999-
else A (a_of_json (Js.Array.unsafe_get array 1))
1000-
else if Stdlib.( = ) tag "B" then
1001-
if Stdlib.( <> ) len 2 then
1002-
Ppx_deriving_json_runtime.of_json_msg_error ~json:x
1003-
"expected a JSON array of length 2"
1004-
else B (b_of_json (Js.Array.unsafe_get array 1))
1005-
else
1006-
Ppx_deriving_json_errors.of_json_error ~json:x
1007-
"expected [\"B\", _] or [\"A\", _]"
1008-
else
1009-
Ppx_deriving_json_runtime.of_json_error ~json:x
1010-
"expected a non empty JSON array with element being a string"
1011-
else
1012-
Ppx_deriving_json_runtime.of_json_error ~json:x
1013-
"expected a non empty JSON array"
1014-
else
1015-
Ppx_deriving_json_runtime.of_json_error ~json:x
1016-
"expected a non empty JSON array"
989+
let rec p2_of_json a_of_json b_of_json =
990+
(fun x ->
991+
if Js.Array.isArray x then
992+
let array = (Obj.magic x : Js.Json.t array) in
993+
let len = Js.Array.length array in
994+
if Stdlib.( > ) len 0 then
995+
let tag = Js.Array.unsafe_get array 0 in
996+
if Stdlib.( = ) (Js.typeof tag) "string" then
997+
let tag = (Obj.magic tag : string) in
998+
if Stdlib.( = ) tag "A" then
999+
if Stdlib.( <> ) len 2 then
1000+
Ppx_deriving_json_runtime.of_json_msg_error ~json:x
1001+
"expected a JSON array of length 2"
1002+
else A (a_of_json (Js.Array.unsafe_get array 1))
1003+
else if Stdlib.( = ) tag "B" then
1004+
if Stdlib.( <> ) len 2 then
1005+
Ppx_deriving_json_runtime.of_json_msg_error ~json:x
1006+
"expected a JSON array of length 2"
1007+
else B (b_of_json (Js.Array.unsafe_get array 1))
1008+
else
1009+
Ppx_deriving_json_errors.of_json_error ~json:x
1010+
"expected [\"B\", _] or [\"A\", _]"
1011+
else
1012+
Ppx_deriving_json_runtime.of_json_error ~json:x
1013+
"expected a non empty JSON array with element being a \
1014+
string"
1015+
else
1016+
Ppx_deriving_json_runtime.of_json_error ~json:x
1017+
"expected a non empty JSON array"
1018+
else
1019+
Ppx_deriving_json_runtime.of_json_error ~json:x
1020+
"expected a non empty JSON array"
1021+
: Js.Json.t -> ('a, 'b) p2)
10171022

10181023
let _ = p2_of_json
10191024

10201025
[@@@ocaml.warning "-39-11-27"]
10211026

1022-
let rec p2_to_json a_to_json b_to_json : ('a, 'b) p2 -> Js.Json.t =
1023-
fun x ->
1024-
match x with
1025-
| A x_0 ->
1026-
(Obj.magic [| (Obj.magic "A" : Js.Json.t); a_to_json x_0 |]
1027-
: Js.Json.t)
1028-
| B x_0 ->
1029-
(Obj.magic [| (Obj.magic "B" : Js.Json.t); b_to_json x_0 |]
1030-
: Js.Json.t)
1027+
let rec p2_to_json a_to_json b_to_json =
1028+
(fun x ->
1029+
match x with
1030+
| A x_0 ->
1031+
(Obj.magic [| (Obj.magic "A" : Js.Json.t); a_to_json x_0 |]
1032+
: Js.Json.t)
1033+
| B x_0 ->
1034+
(Obj.magic [| (Obj.magic "B" : Js.Json.t); b_to_json x_0 |]
1035+
: Js.Json.t)
1036+
: ('a, 'b) p2 -> Js.Json.t)
10311037

10321038
let _ = p2_to_json
10331039
end [@@ocaml.doc "@inline"] [@@merlin.hide]

ppx/test/ppx_deriving_json_native.t

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@
5252
5353
[@@@ocaml.warning "-39-11-27"]
5454
55-
let rec param_of_json a_of_json : Yojson.Basic.t -> 'a param =
56-
fun x -> a_of_json x
55+
let rec param_of_json a_of_json =
56+
(fun x -> a_of_json x : Yojson.Basic.t -> 'a param)
5757

5858
let _ = param_of_json
5959

6060
[@@@ocaml.warning "-39-11-27"]
6161

62-
let rec param_to_json a_to_json : 'a param -> Yojson.Basic.t =
63-
fun x -> a_to_json x
62+
let rec param_to_json a_to_json =
63+
(fun x -> a_to_json x : 'a param -> Yojson.Basic.t)
6464
6565
let _ = param_to_json
6666
end [@@ocaml.doc "@inline"] [@@merlin.hide]
@@ -566,22 +566,25 @@
566566
567567
[@@@ocaml.warning "-39-11-27"]
568568
569-
let rec c_of_json a_of_json : Yojson.Basic.t -> 'a c =
570-
fun x ->
571-
match x with
572-
| `List [ `String "C"; x_0 ] -> `C (a_of_json x_0)
573-
| x ->
574-
raise
575-
(Ppx_deriving_json_runtime.Of_json_error
576-
(Ppx_deriving_json_runtime.Unexpected_variant
577-
"unexpected variant"))
569+
let rec c_of_json a_of_json =
570+
(fun x ->
571+
match x with
572+
| `List [ `String "C"; x_0 ] -> `C (a_of_json x_0)
573+
| x ->
574+
raise
575+
(Ppx_deriving_json_runtime.Of_json_error
576+
(Ppx_deriving_json_runtime.Unexpected_variant
577+
"unexpected variant"))
578+
: Yojson.Basic.t -> 'a c)
578579

579580
let _ = c_of_json
580581

581582
[@@@ocaml.warning "-39-11-27"]
582583

583-
let rec c_to_json a_to_json : 'a c -> Yojson.Basic.t =
584-
fun x -> match x with `C x_0 -> `List [ `String "C"; a_to_json x_0 ]
584+
let rec c_to_json a_to_json =
585+
(fun x ->
586+
match x with `C x_0 -> `List [ `String "C"; a_to_json x_0 ]
587+
: 'a c -> Yojson.Basic.t)
585588
586589
let _ = c_to_json
587590
end [@@ocaml.doc "@inline"] [@@merlin.hide]
@@ -736,24 +739,26 @@
736739
737740
[@@@ocaml.warning "-39-11-27"]
738741
739-
let rec p2_of_json a_of_json b_of_json : Yojson.Basic.t -> ('a, 'b) p2 =
740-
fun x ->
741-
match x with
742-
| `List [ `String "A"; x_0 ] -> A (a_of_json x_0)
743-
| `List [ `String "B"; x_0 ] -> B (b_of_json x_0)
744-
| _ ->
745-
Ppx_deriving_json_runtime.of_json_error ~json:x
746-
"expected [\"A\", _] or [\"B\", _]"
742+
let rec p2_of_json a_of_json b_of_json =
743+
(fun x ->
744+
match x with
745+
| `List [ `String "A"; x_0 ] -> A (a_of_json x_0)
746+
| `List [ `String "B"; x_0 ] -> B (b_of_json x_0)
747+
| _ ->
748+
Ppx_deriving_json_runtime.of_json_error ~json:x
749+
"expected [\"A\", _] or [\"B\", _]"
750+
: Yojson.Basic.t -> ('a, 'b) p2)
747751
748752
let _ = p2_of_json
749753
750754
[@@@ocaml.warning "-39-11-27"]
751755
752-
let rec p2_to_json a_to_json b_to_json : ('a, 'b) p2 -> Yojson.Basic.t =
753-
fun x ->
754-
match x with
755-
| A x_0 -> `List [ `String "A"; a_to_json x_0 ]
756-
| B x_0 -> `List [ `String "B"; b_to_json x_0 ]
756+
let rec p2_to_json a_to_json b_to_json =
757+
(fun x ->
758+
match x with
759+
| A x_0 -> `List [ `String "A"; a_to_json x_0 ]
760+
| B x_0 -> `List [ `String "B"; b_to_json x_0 ]
761+
: ('a, 'b) p2 -> Yojson.Basic.t)
757762
758763
let _ = p2_to_json
759764
end [@@ocaml.doc "@inline"] [@@merlin.hide]

0 commit comments

Comments
 (0)