Commit b66c59df authored by Thierry Martinez's avatar Thierry Martinez
Browse files

Fix examples for using ppx_show/ppx_compare instead of ppx_deriving

parent 71cf58f8
Pipeline #85198 passed with stages
in 41 minutes and 19 seconds
(executable
(name longident_show)
(preprocess (staged_pps override ppx_deriving.show))
(libraries compiler-libs.common))
(preprocess (staged_pps override ppx_show))
(libraries compiler-libs.common ppx_show.runtime))
......@@ -7,7 +7,7 @@ end
let test () =
assert (
Longident.show (Longident.parse "Foo.Bar.baz") =
{|(Longident.Ldot ((Longident.Ldot ((Longident.Lident "Foo"), "Bar")), "baz"))|}
{|Longident.Ldot (Longident.Ldot ((Longident.Lident "Foo"), "Bar"), "baz")|}
)
......
(executable
(name package_type)
(preprocess (staged_pps override ppxlib.metaquot ppx_deriving.show))
(libraries compiler-libs.common))
(preprocess (staged_pps override ppxlib.metaquot ppx_show))
(libraries compiler-libs.common ppx_show.runtime))
......@@ -29,10 +29,13 @@
type package_type = _ [@@deriving show]
end]
let core_type_of_string s =
let lexbuf = Lexing.from_string s in
Parser.parse_core_type Lexer.token lexbuf
let test () =
let loc = Location.none in
let ptyp =
match ([%type: (module S with type t1 = t2)] : Parsetree.core_type) with
match core_type_of_string {|(module S with type t1 = t2)|} with
| { ptyp_desc = Ptyp_package ptyp; _ } -> ptyp
| _ -> assert false in
assert (show_package_type ptyp = "(S, [(t1, t2)])")
......
(executable
(name ppxlib_ast)
(preprocess (staged_pps override ppxlib.metaquot ppx_deriving.eq))
(preprocess (staged_pps override ppxlib.metaquot ppx_compare))
(libraries compiler-libs.common))
(rule
......
......@@ -2,6 +2,8 @@
described in the comments of
https://github.com/ocaml-ppx/ppxlib/blob/master/ast/ast.ml *)
open Ppx_compare_lib.Builtin
(* "- replacing app [type ...] by [and ...] to make everything one
recursive block" *)
[%%recursive
......@@ -60,11 +62,16 @@ recursive block" *)
end
[%%print_rewrite_system]]
[@@deriving eq]
[@@deriving equal]
let structure_of_string s =
let lexbuf = Lexing.from_string s in
Parser.implementation Lexer.token lexbuf
let test () =
let loc = Location.none in
assert (equal_structure [%str (1, 2)] [%str (1, 2)]);
assert (not (equal_structure [%str (1, "a")] [%str (1, "b")]))
assert (equal_structure
(structure_of_string "(1, 2)") (structure_of_string "(1, 2)"));
assert (not (equal_structure
(structure_of_string {|(1, "a")|}) (structure_of_string {|(1, "b")|})))
let () = test ()
......@@ -100,6 +100,7 @@ let collector =
method env = any
method constructor_description = any
method concr = any
method module_presence = any
end
let collect_texp_apply_from_structure (structure : Typedtree.structure)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment