This commit is contained in:
swrup 2025-11-11 02:07:51 +01:00
parent aa2ff7b2f0
commit 2f3113f55d
11742 changed files with 1223940 additions and 0 deletions

View file

@ -0,0 +1 @@
let () = Ppxlib.Driver.standalone ()

View file

@ -0,0 +1,27 @@
(executable
(name driver)
(modules driver)
(enabled_if
(>= %{ocaml_version} "5.2"))
(libraries ppxlib))
(cram
(package ppxlib)
(enabled_if
(>= %{ocaml_version} "5.2"))
(deps driver.exe))
(rule
(package ppxlib)
(alias runtest)
(enabled_if
(>= %{ocaml_version} "5.2"))
(deps
(:test test.ml)
(package ppxlib))
(action
(chdir
%{project_root}
(progn
(run expect-test %{test})
(diff? %{test} %{test}.corrected)))))

View file

@ -0,0 +1,19 @@
We want to make sure that migrations from 5.2 to previous versions still
produce valid location ranges between parent and child.
$ cat > test.ml << EOF
> let make ~foo ~bar = foo ^ bar
> EOF
We run a custom driver that will read our ast, migrate it back to 5.01, and
check that the locations are valid (the parent range is larger than the child
range).
$ ./driver.exe -locations-check --impl test.ml -o ignore.ml
Locations should also be well formed for Pparam_newtype
$ cat > test.ml << EOF
> let make (type t) (type u) foo = foo
> EOF
$ ./driver.exe -locations-check --impl test.ml -o ignore.ml

View file

@ -0,0 +1,23 @@
open Ppxlib
module B = Ast_builder.Make (struct
let loc = !Ast_helper.default_loc
end)
[%%ignore]
(** Using multiple calls to [pexp_fun] still produces a maximum arity function
*)
let _ =
let inner =
B.pexp_fun Nolabel None
(B.ppat_var { txt = "y"; loc = B.loc })
(B.pexp_apply (B.evar "Int.add")
[ (Nolabel, B.evar "x"); (Nolabel, B.evar "y") ])
in
let e =
B.pexp_fun Nolabel None (B.ppat_var { txt = "x"; loc = B.loc }) inner
in
Format.asprintf "%a" Pprintast.expression e
[%%expect{|
- : string = "fun x y -> Int.add x y"
|}]