-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
237 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# This file is generated by dune, edit dune-project instead | ||
opam-version: "2.0" | ||
version: "3.0.1" | ||
synopsis: | ||
"Runtime library for ocaml-protoc to support tests based on quickcheck" | ||
maintainer: ["Maxime Ransan <[email protected]>" "Simon Cruanes"] | ||
authors: ["Maxime Ransan <[email protected]>" "Simon Cruanes"] | ||
license: "MIT" | ||
tags: ["protobuf" "encode" "decode" "quickcheck" "rpc"] | ||
homepage: "https://github.com/mransan/ocaml-protoc" | ||
bug-reports: "https://github.com/mransan/ocaml-protoc/issues" | ||
depends: [ | ||
"dune" {>= "2.0"} | ||
"ocaml" {>= "4.08"} | ||
"pbrt" {= version} | ||
"pbrt_yojson" {= version} | ||
] | ||
build: [ | ||
["dune" "subst"] {pinned} | ||
[ | ||
"dune" | ||
"build" | ||
"-p" | ||
name | ||
"-j" | ||
jobs | ||
"@install" | ||
"@runtest" {with-test} | ||
"@doc" {with-doc} | ||
] | ||
] | ||
dev-repo: "git+https://github.com/mransan/ocaml-protoc.git" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
module Ot = Pb_codegen_ocaml_type | ||
module F = Pb_codegen_formatting | ||
|
||
let type_name t = | ||
match t with | ||
| { Ot.spec = Ot.Record { Ot.r_name; _ }; _ } -> r_name | ||
| { Ot.spec = Ot.Variant v; _ } -> v.Ot.v_name | ||
| { Ot.spec = Ot.Const_variant { Ot.cv_name; _ }; _ } -> cv_name | ||
| { Ot.spec = Ot.Unit { Ot.er_name; _ }; _ } -> er_name | ||
|
||
let gen_sig ?and_:_ t sc = | ||
let type_name = type_name t in | ||
F.linep sc "val quickcheck_%s : %s Pbrt_quickcheck.Type_class.t" type_name | ||
type_name; | ||
F.linep sc | ||
"(** [quickcheck_%s] contains helpers to test the type %s with quickcheck \ | ||
*)" | ||
type_name type_name; | ||
true | ||
|
||
let gen_struct ?and_:_ t sc = | ||
let type_name = type_name t in | ||
F.linep sc "let quickcheck_%s =" type_name; | ||
F.linep sc " { Pbrt_quickcheck.Type_class."; | ||
let field f = F.linep sc " %s = %s_%s;" f f type_name in | ||
List.iter field | ||
[ "pp"; "equal"; "encode_pb"; "decode_pb"; "encode_json"; "decode_json" ]; | ||
F.linep sc " }"; | ||
|
||
true | ||
|
||
let ocamldoc_title = "QuickCheck" | ||
let requires_mutable_records = false | ||
|
||
let plugin : Pb_codegen_plugin.t = | ||
let module P = struct | ||
let gen_sig = gen_sig | ||
let gen_struct = gen_struct | ||
let ocamldoc_title = ocamldoc_title | ||
let requires_mutable_records = requires_mutable_records | ||
end in | ||
(module P) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
(** Plugin that generates values for QuickCheck tests. *) | ||
|
||
include Pb_codegen_plugin.S | ||
|
||
val plugin : Pb_codegen_plugin.t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(library | ||
(public_name pbrt_quickcheck) | ||
(wrapped false) | ||
(libraries | ||
pbrt | ||
(re_export qcheck) | ||
yojson)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
(** Runtime for QuickCheck based tests. *) | ||
|
||
(** A type class generated for each type *) | ||
module Type_class = struct | ||
type 'a t = { | ||
pp: Format.formatter -> 'a -> unit; | ||
equal: 'a -> 'a -> bool; | ||
encode_pb: 'a -> Pbrt.Encoder.t -> unit; | ||
decode_pb: Pbrt.Decoder.t -> 'a; | ||
encode_json: 'a -> Yojson.Basic.t; | ||
decode_json: Yojson.Basic.t -> 'a; | ||
} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.