test
This commit is contained in:
parent
459f6a7888
commit
d5e5a441b6
13 changed files with 81 additions and 4 deletions
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"ocaml.sandbox": {
|
||||
"kind": "global"
|
||||
}
|
||||
}
|
3
bin/dune
3
bin/dune
|
@ -1,4 +1,5 @@
|
|||
(executable
|
||||
(public_name poplpaper)
|
||||
(name main)
|
||||
(libraries poplpaper))
|
||||
(libraries ppx_poplpaper)
|
||||
(preprocess (pps ppx_poplpaper)))
|
||||
|
|
|
@ -1 +1,5 @@
|
|||
(lang dune 2.9)
|
||||
|
||||
(name ppx_poplpaper)
|
||||
|
||||
(generate_opam_files true)
|
|
@ -7,7 +7,11 @@
|
|||
in {
|
||||
devShell = pkgs.mkShell {
|
||||
inputsFrom = with flakePkgs; [ main ];
|
||||
packages = with pkgs; [ ocamlPackages.ocaml-lsp ];
|
||||
packages = (with pkgs; [ ]) ++ (with pkgs.ocamlPackages; [ocaml-lsp ppxlib
|
||||
alcotest
|
||||
yojson
|
||||
ezjsonm
|
||||
]);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
6
lib/dune
6
lib/dune
|
@ -1,2 +1,6 @@
|
|||
(library
|
||||
(name poplpaper))
|
||||
(name ppx_poplpaper)
|
||||
(public_name ppx_poplpaper)
|
||||
(kind ppx_rewriter)
|
||||
(libraries ppxlib)
|
||||
(preprocess (pps ppxlib.metaquot)))
|
||||
|
|
19
lib/ppx_poplpaper.ml
Normal file
19
lib/ppx_poplpaper.ml
Normal file
|
@ -0,0 +1,19 @@
|
|||
(* https://tarides.com/blog/2019-05-09-an-introduction-to-ocaml-ppx-ecosystem/ *)
|
||||
|
||||
open Ppxlib
|
||||
|
||||
let expand ~ctxt:_ (expr: expression) =
|
||||
expr
|
||||
|
||||
let ext = Extension.V3.declare
|
||||
"monomorphic"
|
||||
Extension.Context.expression
|
||||
Ast_pattern.(single_expr_payload __)
|
||||
expand
|
||||
|
||||
let rule = Context_free.Rule.extension ext
|
||||
|
||||
let () =
|
||||
Driver.register_transformation
|
||||
~rules:[rule]
|
||||
"monomorphic"
|
22
ppx_poplpaper.opam
Normal file
22
ppx_poplpaper.opam
Normal file
|
@ -0,0 +1,22 @@
|
|||
# This file is generated by dune, edit dune-project instead
|
||||
opam-version: "2.0"
|
||||
depends: [
|
||||
"dune" {>= "2.9"}
|
||||
"odoc" {with-doc}
|
||||
]
|
||||
build: [
|
||||
["dune" "subst"] {dev}
|
||||
[
|
||||
"dune"
|
||||
"build"
|
||||
"-p"
|
||||
name
|
||||
"-j"
|
||||
jobs
|
||||
"--promote-install-files=false"
|
||||
"@install"
|
||||
"@runtest" {with-test}
|
||||
"@doc" {with-doc}
|
||||
]
|
||||
["dune" "install" "-p" name "--create-install-files" name]
|
||||
]
|
4
test/bin/dune
Normal file
4
test/bin/dune
Normal file
|
@ -0,0 +1,4 @@
|
|||
(executable
|
||||
(name pp)
|
||||
(modules pp)
|
||||
(libraries ppx_poplpaper ppxlib))
|
1
test/bin/pp.ml
Normal file
1
test/bin/pp.ml
Normal file
|
@ -0,0 +1 @@
|
|||
Ppxlib.Driver.standalone ()
|
13
test/dune
13
test/dune
|
@ -1,2 +1,13 @@
|
|||
(rule
|
||||
(targets test.actual.ml)
|
||||
(deps test.ml)
|
||||
(action (run ./bin/pp.exe --impl %{deps} -o %{targets})))
|
||||
|
||||
(rule
|
||||
(alias runtest)
|
||||
(action (diff test.expected.ml test.actual.ml)))
|
||||
|
||||
(test
|
||||
(name poplpaper))
|
||||
(name test)
|
||||
(modules test)
|
||||
(preprocess (pps ppx_poplpaper)))
|
2
test/test.ml
Normal file
2
test/test.ml
Normal file
|
@ -0,0 +1,2 @@
|
|||
let%monomorphic prop0 (f : 'a -> 'b) (xs : 'a List.t) : bool =
|
||||
List.length (List.map f xs) = 0
|
Loading…
Reference in a new issue