-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from NathanReb/extract-ppx-yojson-lib
Extract Ppx_yojson_lib and tests
- Loading branch information
Showing
15 changed files
with
116 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
(library | ||
(name ppx_yojson_lib) | ||
(public_name ppx_yojson._lib) | ||
(libraries | ||
ppxlib | ||
) | ||
(preprocess | ||
(pps | ||
ppxlib.metaquot | ||
) | ||
) | ||
) |
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,11 @@ | ||
module Einteger : sig | ||
val is_binary : Ppxlib.label -> bool | ||
val is_octal : Ppxlib.label -> bool | ||
val is_hexadecimal : Ppxlib.label -> bool | ||
end | ||
|
||
val expand_expr : | ||
loc: Ppxlib.Location.t -> | ||
path: string -> | ||
Ppxlib.expression -> | ||
Ppxlib.expression |
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
(public_name ppx_yojson) | ||
(kind ppx_rewriter) | ||
(libraries | ||
ppx_yojson_lib | ||
ppxlib | ||
) | ||
(preprocess | ||
|
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,17 @@ | ||
open Ppxlib | ||
|
||
let name = "yojson" | ||
|
||
let expr_extension = | ||
Extension.declare | ||
name | ||
Extension.Context.expression | ||
Ast_pattern.(single_expr_payload __) | ||
Ppx_yojson_lib.expand_expr | ||
|
||
let expr_rule = Ppxlib.Context_free.Rule.extension expr_extension | ||
|
||
let () = | ||
Ppxlib.Driver.register_transformation | ||
~rules:[expr_rule] | ||
name |
File renamed without changes.
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,12 @@ | ||
(test | ||
(name test_ppx_yojson_lib) | ||
(libraries | ||
ppx_yojson_lib | ||
oUnit | ||
) | ||
(preprocess | ||
(pps | ||
ppx_deriving.std | ||
) | ||
) | ||
) |
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,44 @@ | ||
open OUnit2 | ||
|
||
module Einteger = struct | ||
let test_is_binary = | ||
let test = Utils.test_prop Ppx_yojson_lib.Einteger.is_binary in | ||
let open Utils.Infix in | ||
"is_binary" >::: | ||
[ "0b1" >:= test true | ||
; "0B1" >:= test true | ||
; "123" >:= test false | ||
] | ||
|
||
let test_is_octal = | ||
let test = Utils.test_prop Ppx_yojson_lib.Einteger.is_octal in | ||
let open Utils.Infix in | ||
"is_octal" >::: | ||
[ "0o1" >:= test true | ||
; "0O1" >:= test true | ||
; "123" >:= test false | ||
] | ||
|
||
let test_is_hexadecimal = | ||
let test = Utils.test_prop Ppx_yojson_lib.Einteger.is_hexadecimal in | ||
let open Utils.Infix in | ||
"is_hexadecimal" >::: | ||
[ "0x1" >:= test true | ||
; "0X1" >:= test true | ||
; "123" >:= test false | ||
] | ||
|
||
let suite = | ||
"Einteger" >::: | ||
[ test_is_binary | ||
; test_is_octal | ||
; test_is_hexadecimal | ||
] | ||
end | ||
|
||
let suite = | ||
"Ppx_yojson_lib" >::: | ||
[ Einteger.suite | ||
] | ||
|
||
let () = run_test_tt_main suite |
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,9 @@ | ||
open OUnit2 | ||
|
||
let test_prop prop expected input ctxt = | ||
let actual = prop input in | ||
assert_equal ~ctxt ~cmp:[%eq: bool] ~printer:[%show: bool] expected actual | ||
|
||
module Infix = struct | ||
let (>:=) name test = name >:: test name | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
(** Test function for properties. | ||
[test_prop prop expected input ctxt] is [assert_equal ~ctxt expected (prop input)] | ||
*) | ||
val test_prop : ('a -> bool) -> bool -> 'a -> OUnit2.test_ctxt -> unit | ||
|
||
module Infix : sig | ||
(** Create a test which also takes its label as input *) | ||
val (>:=) : string -> (string -> OUnit2.test_fun) -> OUnit2.test | ||
end |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.