Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an exponential generator #298

Merged
merged 6 commits into from
Dec 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add expect tests of exponential
  • Loading branch information
jmid committed Dec 7, 2024
commit 1624c881b2509cabeb7624f7819c9f1cc1132811
7 changes: 7 additions & 0 deletions test/core/QCheck2_tests.ml
Original file line number Diff line number Diff line change
@@ -883,6 +883,12 @@ module Stats = struct
Test.make ~name:"oneof int dist" ~count:1000 ~stats:[dist] (Gen.oneofl[min_int;-1;0;1;max_int]) (fun _ -> true);
]

let exponential_tests =
let float_dist = ("dist",int_of_float) in
[ Test.make ~name:"exponential 10. dist" ~count:5_000 ~stats:[float_dist] (Gen.exponential 10.) (fun _ -> true);
Test.make ~name:"exponential -10. dist" ~count:5_000 ~stats:[float_dist] (Gen.exponential (-10.)) (fun _ -> true);
]

let tree_depth_test =
let depth = ("depth", IntTree.depth) in
Test.make ~name:"tree's depth" ~count:1000 ~stats:[depth] IntTree.gen_tree (fun _ -> true)
@@ -904,4 +910,5 @@ module Stats = struct
@ list_len_tests
@ array_len_tests
@ int_dist_tests
@ exponential_tests
end
7 changes: 7 additions & 0 deletions test/core/QCheck_tests.ml
Original file line number Diff line number Diff line change
@@ -955,6 +955,12 @@ module Stats = struct
Test.make ~name:"oneof int dist" ~count:1000 (add_stat dist (oneofl[min_int;-1;0;1;max_int])) (fun _ -> true);
]

let exponential_tests =
let float_dist = ("dist",int_of_float) in
[ Test.make ~name:"exponential 10. dist" ~count:5_000 (add_stat float_dist (exponential 10.)) (fun _ -> true);
Test.make ~name:"exponential -10. dist" ~count:5_000 (add_stat float_dist (exponential (-10.))) (fun _ -> true);
]

let tree_depth_test =
let depth = ("depth", IntTree.depth) in
Test.make ~name:"tree's depth" ~count:1000 (add_stat depth (make IntTree.gen_tree)) (fun _ -> true)
@@ -982,4 +988,5 @@ module Stats = struct
@ list_len_tests
@ array_len_tests
@ int_dist_tests
@ exponential_tests
end