Skip to content

Commit 962312e

Browse files
KakaduDmitrii.Kosarev a.k.a. Kakadu
authored and
Dmitrii.Kosarev a.k.a. Kakadu
committed
[ppx] Update ppx_tester to accept less arguments
Signed-off-by: Dmitrii.Kosarev a.k.a. Kakadu <[email protected]>
1 parent e67ebd7 commit 962312e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

ppx/tester/ppx_tester.ml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ open Ppxlib
2828
let string_of_expression e =
2929
Format.set_margin 1000;
3030
Format.set_max_indent 0;
31-
let ans = Format.asprintf "%a" Pprintast.expression e in
32-
ans
31+
Format.asprintf "%a" Pprintast.expression e
3332
;;
3433

3534
let name = "tester"
@@ -42,23 +41,25 @@ let () =
4241
(pstr_eval
4342
(pexp_apply
4443
__
45-
((nolabel ** __) ^:: (nolabel ** __) ^:: (nolabel ** __) ^:: (nolabel ** __) ^:: nil))
44+
((nolabel ** __) ^:: (nolabel ** __) ^:: (nolabel ** __) ^:: (nolabel ** __) ^:: nil
45+
|> map2 ~f:(fun a b -> [ a; b ])
46+
||| ((nolabel ** __) ^:: (nolabel ** __) ^:: nil |> map0 ~f:[])))
4647
nil
4748
^:: nil)
4849
in
4950
[ Extension.declare
5051
name
5152
Extension.Context.Expression
5253
pattern
53-
(fun ~loc ~path:_ runner reifier shower n realtion ->
54+
(fun ~loc ~path:_ runner reifier_shower n relation ->
5455
let open Ppxlib.Ast_builder.Default in
5556
let count =
5657
let rec helper acc e =
5758
match e.pexp_desc with
5859
| Pexp_fun (_, _, _, body) -> helper (1 + acc) body
5960
| _ -> acc
6061
in
61-
helper 0 realtion
62+
helper 0 relation
6263
in
6364
let middle =
6465
match count with
@@ -70,13 +71,13 @@ let () =
7071
| _ -> failwith (Printf.sprintf "5 and more arguments are not supported")
7172
in
7273
let last =
73-
let s = string_of_expression @@ realtion in
74+
let s = string_of_expression relation in
7475
let open Ppxlib.Ast_builder.Default in
75-
[%expr [%e pexp_constant ~loc (Pconst_string (s, loc, None))], [%e realtion]]
76+
[%expr [%e pexp_constant ~loc (Pconst_string (s, loc, None))], [%e relation]]
7677
in
7778
pexp_apply ~loc runner
7879
@@ List.map (fun e -> Nolabel, e)
79-
@@ List.concat [ [ reifier; shower; n ]; middle; [ last ] ])
80+
@@ List.concat [ reifier_shower @ [ n ]; middle; [ last ] ])
8081
]
8182
in
8283
Ppxlib.Driver.register_transformation ~extensions name

0 commit comments

Comments
 (0)