-
Notifications
You must be signed in to change notification settings - Fork 60
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 #140 from Leonidas-from-XIV/atd-example
Add regression test for pretty-printing
- Loading branch information
Showing
4 changed files
with
73 additions
and
9 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,11 @@ | ||
[ | ||
{ "r1": "testing" }, { "r2": [ "Some", 2 ] }, { "r2": "None" }, { | ||
"r3": [ "Some", 3 ] }, {}, { "r4": true }, { "r5": [ "Some", 5 ] }, {}, { | ||
"r6": 6 }, {}, { "r7": -1000 }, { "r8": [ 1, 2, 3 ] }, [ "foo", "bar" ], | ||
[], null, [ 1, 2, 3 ], 99, { "foo": 7, "bar": 8, "baz": 43 }, { "foo2": 5, | ||
"bar2": 6, "baz2": 41, "42": 42 }, [ 100, "foo" ], [ 100, 200, 42 ], [ | ||
100, 200, -1 ], [ | ||
"V1", "v22", [ "V3", "testing" ], [ "V44", 255 ], [ "V5", "None" ], [ | ||
"V5", [ "Some", true ] ] ], { "v2": "A" }, { "v2": [ "B", 100 ] }, [ | ||
"C1", [ "C2", true ], [ "C2", false ] ], [ 50, 30, -1, 400 ] | ||
] |
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,46 @@ | ||
let massive_json = | ||
`List [ | ||
`Assoc [("r1", `String "testing")]; | ||
`Assoc [("r2", `List [`String "Some"; `Int 2])]; | ||
`Assoc [("r2", `String "None")]; | ||
`Assoc [("r3", `List [`String "Some"; `Int 3])]; | ||
`Assoc []; | ||
`Assoc [("r4", `Bool true) ]; | ||
`Assoc [("r5", `List [`String "Some"; `Int 5])]; | ||
`Assoc []; | ||
`Assoc [("r6", `Int 6)]; | ||
`Assoc []; | ||
`Assoc [("r7", `Int (-1_000))]; | ||
`Assoc [("r8", `List [`Int 1; `Int 2; `Int 3])]; | ||
`List [`String "foo"; `String "bar"]; | ||
`List []; | ||
`Null; | ||
`List [`Int 1; `Int 2; `Int 3]; | ||
`Int 99; | ||
`Assoc [("foo", `Int 7); ("bar", `Int 8); ("baz", `Int 43)]; | ||
`Assoc [("foo2", `Int 5); ("bar2", `Int 6); ("baz2", `Int 41); ("42", `Int 42)]; | ||
`List [`Int 100; `String "foo"]; | ||
`List [`Int 100; `Int 200; `Int 42]; | ||
`List [`Int 100; `Int 200; `Int (-1)]; | ||
`List [ | ||
`String "V1"; | ||
`String "v22"; | ||
`List [`String "V3"; `String "testing"]; | ||
`List [`String "V44"; `Int 255]; | ||
`List [`String "V5"; `String "None"]; | ||
`List [`String "V5"; `List [`String "Some"; `Bool true]] | ||
]; | ||
`Assoc [("v2", `String "A")]; | ||
`Assoc [("v2", `List [`String "B"; `Int 100])]; | ||
`List [ | ||
`String "C1"; | ||
`List [`String "C2"; `Bool true]; | ||
`List [`String "C2"; `Bool false]]; | ||
`List[`Int 50; `Int 30; `Int (-1); `Int 400]; | ||
] | ||
|
||
let pp_json fmt json = | ||
Format.pp_print_string fmt (Yojson.Safe.pretty_to_string ~std:true json) | ||
|
||
let () = | ||
Format.printf "%a\n" pp_json massive_json |
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 |
---|---|---|
@@ -1,16 +1,23 @@ | ||
(executable | ||
(name test) | ||
(executables | ||
(names test atd) | ||
(libraries yojson)) | ||
|
||
(rule | ||
(targets test.output) | ||
(deps ./sample.json ./test.exe) | ||
(action | ||
(with-stdout-to | ||
%{targets} | ||
(run ./test.exe)))) | ||
(deps ./sample.json) | ||
(action | ||
(with-stdout-to | ||
test.output.json | ||
(run ./test.exe)))) | ||
|
||
(rule | ||
(action | ||
(with-stdout-to | ||
atd.output.json | ||
(run ./atd.exe)))) | ||
|
||
(alias | ||
(name runtest) | ||
(action | ||
(diff test.expected test.output))) | ||
(progn | ||
(diff test.expected.json test.output.json) | ||
(diff atd.expected.json atd.output.json)))) |
File renamed without changes.