This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
|
|
@ -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)))))
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
open Ppxlib;;
|
||||
open Ast_builder.Default;;
|
||||
|
||||
Driver.register_transformation "blah"
|
||||
~rules:[ Context_free.Rule.extension
|
||||
(Extension.declare "foo"
|
||||
Expression
|
||||
Ast_pattern.(pstr nil)
|
||||
(fun ~loc ~path:_ -> eint ~loc 42))
|
||||
; Context_free.Rule.extension
|
||||
(Extension.declare "@foo.bar"
|
||||
Expression
|
||||
Ast_pattern.(pstr nil)
|
||||
(fun ~loc ~path:_ -> eint ~loc 42))
|
||||
]
|
||||
;;
|
||||
[%%expect{|
|
||||
- : unit = ()
|
||||
|}]
|
||||
|
||||
[%foo];;
|
||||
[%%expect{|
|
||||
- : int = 42
|
||||
|}]
|
||||
|
||||
[%foo.bar];;
|
||||
[%%expect{|
|
||||
- : int = 42
|
||||
|}]
|
||||
|
||||
[%bar];;
|
||||
[%%expect{|
|
||||
Line _, characters 2-5:
|
||||
Error: Uninterpreted extension 'bar'.
|
||||
|}]
|
||||
Loading…
Add table
Add a link
Reference in a new issue