diff options
| author | Puneeth Chaganti <punchagan@muse-amuse.in> | 2024-09-22 08:02:27 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-21 19:32:27 -0700 |
| commit | 25730686a3ca95de7b516e0f7651807c07d58340 (patch) | |
| tree | 2da9a4591c68b07cdba3eeb3e8e9676d03eb6aa4 /test | |
| parent | 407095d817dfde76e8943d389a100876a4c43338 (diff) | |
Add ocp-indent as a formatter (#306)
ocp-indent allows indenting even partially compiling OCaml code, while
ocamlformat requires the code to compile correctly. Also, Doom Emacs
uses ocp-indent when ocamlformat's configuration file is not found, and
not having an ocp-indent formatter gives an error.
<!--
To expedite the pull request process, please see the contributor guide
for my projects:
<https://github.com/raxod502/contributor-guide>
-->
Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
Diffstat (limited to 'test')
| -rw-r--r-- | test/formatters/installers/ocp-indent.bash | 5 | ||||
| -rw-r--r-- | test/formatters/samplecode/ocp-indent/in.ml | 35 | ||||
| -rw-r--r-- | test/formatters/samplecode/ocp-indent/out.ml | 35 |
3 files changed, 75 insertions, 0 deletions
diff --git a/test/formatters/installers/ocp-indent.bash b/test/formatters/installers/ocp-indent.bash new file mode 100644 index 0000000..0e449f2 --- /dev/null +++ b/test/formatters/installers/ocp-indent.bash @@ -0,0 +1,5 @@ +apt-get install -y opam + +opam init -n --disable-sandboxing --root /opt/ocp-indent +opam install ocp-indent -y --root /opt/ocp-indent +ln -s /opt/ocp-indent/default/bin/ocp-indent /usr/local/bin/ diff --git a/test/formatters/samplecode/ocp-indent/in.ml b/test/formatters/samplecode/ocp-indent/in.ml new file mode 100644 index 0000000..d647068 --- /dev/null +++ b/test/formatters/samplecode/ocp-indent/in.ml @@ -0,0 +1,35 @@ +(* https://github.com/OCamlPro/ocp-indent/blob/master/tests/failing/list_of_funs.ml *) + +let f x = + (fun x -> x [ (fun () -> 3) ; + (fun () -> 4) ]) + +let f x = (fun x -> x [ (fun () -> 3) ; + (fun () -> 4) ]) + +let f x = + x [ (fun () -> 3) ; + (fun () -> 4) ] + +let f x = + [ (fun () -> 3) ; + (fun () -> 4) ] + +let f x = + (fun x -> x [ (fun () -> + 3) ; + (fun () -> 4) ]) + +let f x = (fun x -> x [ (fun () -> + 3) ; + (fun () -> 4) ]) + +let f x = + x [ (fun () -> + 3) ; + (fun () -> 4) ] + +let f x = + [ (fun () -> + 3) ; + (fun () -> 4) ] diff --git a/test/formatters/samplecode/ocp-indent/out.ml b/test/formatters/samplecode/ocp-indent/out.ml new file mode 100644 index 0000000..dddb26b --- /dev/null +++ b/test/formatters/samplecode/ocp-indent/out.ml @@ -0,0 +1,35 @@ +(* https://github.com/OCamlPro/ocp-indent/blob/master/tests/failing/list_of_funs.ml *) + +let f x = + (fun x -> x [ (fun () -> 3) ; + (fun () -> 4) ]) + +let f x = (fun x -> x [ (fun () -> 3) ; + (fun () -> 4) ]) + +let f x = + x [ (fun () -> 3) ; + (fun () -> 4) ] + +let f x = + [ (fun () -> 3) ; + (fun () -> 4) ] + +let f x = + (fun x -> x [ (fun () -> + 3) ; + (fun () -> 4) ]) + +let f x = (fun x -> x [ (fun () -> + 3) ; + (fun () -> 4) ]) + +let f x = + x [ (fun () -> + 3) ; + (fun () -> 4) ] + +let f x = + [ (fun () -> + 3) ; + (fun () -> 4) ] |
