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,14 @@
(rule
(package ppxlib)
(alias runtest)
(enabled_if
(>= %{ocaml_version} "4.08.0"))
(deps
(:test test.ml)
(package ppxlib))
(action
(chdir
%{project_root}
(progn
(run expect-test %{test})
(diff? %{test} %{test}.corrected)))))

View file

@ -0,0 +1,53 @@
open Ppxlib
open Expansion_helpers
module Ast = Ast_builder.Default
[%%expect{|
module Ast = Ppxlib.Ast_builder.Default
|}]
let quoter = Quoter.create ();;
[%%expect{|
val quoter : Quoter.t = <abstr>
|}]
let expr1 =
Ast.evar "foo" ~loc:Location.none
|> Quoter.quote quoter
[%%ignore]
Pprintast.string_of_expression expr1;;
[%%expect{|
- : string = "__0"
|}]
let expr2 =
Ast_builder.Default.evar ~loc:Location.none "bar"
|> Quoter.quote quoter
[%%ignore]
Pprintast.string_of_expression expr2;;
[%%expect{|
- : string = "__1"
|}]
let expr3 =
Ast.eapply ~loc:Location.none (Ast.evar "foo" ~loc:Location.none) [Ast.eunit ~loc:Location.none]
|> Quoter.quote quoter
[%%ignore]
Pprintast.string_of_expression expr3;;
[%%expect{|
- : string = "__2 ()"
|}]
let quoted =
let expr = Ast.elist ~loc:Location.none [expr1; expr2; expr3] in
Quoter.sanitize quoter expr
[%%ignore]
Pprintast.string_of_expression quoted;;
[%%expect{|
- : string =
"let __2 () = foo ()\nand __1 = bar\nand __0 = foo in [__0; __1; __2 ()]"
|}]