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

QCheck 1/2 expect tests #153

Merged
merged 53 commits into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
ff6a377
test: add package on main test
c-cube Aug 9, 2021
f163a46
fix overflow
jmid Aug 10, 2021
5ca4219
avoid repeated conversion
jmid Aug 10, 2021
5d055dd
clean-up rep.code
jmid Aug 10, 2021
ea6a2f6
initial version
jmid Aug 11, 2021
b046799
add fun prop illustrating fun-last advantage
jmid Aug 11, 2021
15368f3
collect tests thematically in sub-modules
jmid Aug 11, 2021
f3085df
add tests from issue #59
jmid Aug 11, 2021
9eb04eb
add test (and char dist) from issue #23
jmid Aug 12, 2021
0cd4f57
rename to *int_*stat tests
jmid Aug 12, 2021
141d8ac
comment tests with issue/PR
jmid Aug 12, 2021
a7fe546
add bool dist test
jmid Aug 12, 2021
9e223d1
add list dist test
jmid Aug 12, 2021
594b6ae
add small_list+list_(of_)size test
jmid Aug 12, 2021
1b594e9
collect list dist tests
jmid Aug 12, 2021
77d745c
add array and repeat tests
jmid Aug 12, 2021
5415524
rename int dist tests to make it easier to add more
jmid Aug 12, 2021
9334a06
clean-up: avoid repeated 'let open QCheck', take ~name first, rename
jmid Aug 12, 2021
fa0ac05
add string dist tests
jmid Aug 12, 2021
51075bf
add false string tests
jmid Aug 12, 2021
c206713
restructure tests into positive (Generator) / negative (Shrink)
jmid Aug 13, 2021
fed8815
add pos and neg char tests
jmid Aug 13, 2021
762e365
add list tests (and a fun test) from issue #64
jmid Aug 13, 2021
2ebfec6
add more int shrinker tests (with a comparable trace)
jmid Aug 13, 2021
c809826
Merge branch 'master' into qcheck1-2-expect-tests
jmid Aug 13, 2021
a61a7e3
Merge pull request #151 from jmid/stat-overflow
c-cube Aug 13, 2021
3f3261d
Fix the tests and remove out of place (optional)
kit-ty-kate Aug 15, 2021
8a0f030
Merge pull request #154 from kit-ty-kate/fix-0
c-cube Aug 15, 2021
13ea8d6
initial version
jmid Aug 11, 2021
f02ea4b
add fun prop illustrating fun-last advantage
jmid Aug 11, 2021
f53a367
collect tests thematically in sub-modules
jmid Aug 11, 2021
dc77432
add tests from issue #59
jmid Aug 11, 2021
31a8e0c
add test (and char dist) from issue #23
jmid Aug 12, 2021
b654066
rename to *int_*stat tests
jmid Aug 12, 2021
658476c
comment tests with issue/PR
jmid Aug 12, 2021
4223405
add bool dist test
jmid Aug 12, 2021
3abcc7f
add list dist test
jmid Aug 12, 2021
f0f73fd
add small_list+list_(of_)size test
jmid Aug 12, 2021
2bd471f
collect list dist tests
jmid Aug 12, 2021
42a280e
add array and repeat tests
jmid Aug 12, 2021
d4ab9d3
rename int dist tests to make it easier to add more
jmid Aug 12, 2021
0f96fdb
clean-up: avoid repeated 'let open QCheck', take ~name first, rename
jmid Aug 12, 2021
de2d048
add string dist tests
jmid Aug 12, 2021
8680e54
add false string tests
jmid Aug 12, 2021
da024c9
restructure tests into positive (Generator) / negative (Shrink)
jmid Aug 13, 2021
25dc533
add pos and neg char tests
jmid Aug 13, 2021
06f1504
add list tests (and a fun test) from issue #64
jmid Aug 13, 2021
03f4791
add more int shrinker tests (with a comparable trace)
jmid Aug 13, 2021
6acdeb5
add string empty test
jmid Aug 16, 2021
9f7a282
update expected output following PR #151
jmid Aug 16, 2021
460a280
add unique list test
jmid Aug 17, 2021
80431cc
resolve merge conflict
jmid Aug 17, 2021
e7efdf1
add nat tests
jmid Aug 17, 2021
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
2 changes: 1 addition & 1 deletion example/alcotest/dune
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
(rule
(targets output.txt)
(deps ./QCheck_alcotest_test.exe)
(package qcheck-alcotest)
(enabled_if (= %{os_type} "Unix"))
(action
(with-accepted-exit-codes
Expand All @@ -19,5 +18,6 @@

(rule
(alias runtest)
(package qcheck-alcotest)
(enabled_if (= %{os_type} "Unix"))
(action (diff output.txt.expected output.txt)))
2 changes: 1 addition & 1 deletion example/dune
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
(rule
(targets output.txt)
(deps ./QCheck_runner_test.exe)
(package qcheck-core)
(enabled_if (= %{os_type} "Unix"))
(action
(with-accepted-exit-codes
Expand All @@ -18,4 +17,5 @@
(rule
(alias runtest)
(enabled_if (= %{os_type} "Unix"))
(package qcheck)
(action (diff output.txt.expected output.txt)))
4 changes: 2 additions & 2 deletions example/ounit/dune
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

(executables
(names QCheck_ounit_test QCheck_test)
(libraries qcheck ounit2 qcheck-ounit))
(libraries ounit2 qcheck-ounit))

(rule
(targets output.txt)
(deps ./QCheck_ounit_test.exe)
(package qcheck-ounit)
(enabled_if (= %{os_type} "Unix"))
(action
(with-accepted-exit-codes
Expand All @@ -17,5 +16,6 @@

(rule
(alias runtest)
(package qcheck-ounit)
(enabled_if (= %{os_type} "Unix"))
(action (diff output.txt.expected output.txt)))
15 changes: 9 additions & 6 deletions src/core/QCheck2.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1693,20 +1693,24 @@ module Test = struct
median := i));
(* group by buckets, if there are too many entries: *)
(* first compute histogram and bucket size *)
let min_idx64, max_idx64 = Int64.(of_int min_idx, of_int max_idx) in
let hist_size, bucket_size =
let sample_width = Int64.(sub (of_int max_idx) (of_int min_idx)) in
let sample_width = Int64.sub max_idx64 min_idx64 in
if sample_width > Int64.of_int stat_max_lines
then stat_max_lines,
int_of_float (ceil (Int64.to_float sample_width /. float_of_int stat_max_lines))
else max_idx-min_idx, 1
in
let hist_size = if min_idx + bucket_size * hist_size <= max_idx then 1+hist_size else hist_size in
let hist_size =
if Int64.(add min_idx64 (mul (of_int bucket_size) (of_int hist_size))) <= max_idx64
then 1+hist_size
else hist_size in
(* accumulate bucket counts *)
let max_val = ref 0 in (* max value after grouping by buckets *)
let bucket_count = Array.init hist_size (fun _ -> 0) in
Hashtbl.iter
(fun j count ->
let bucket = Int64.(to_int (div (sub (of_int j) (of_int min_idx)) (of_int bucket_size))) in
let bucket = Int64.(to_int (div (sub (of_int j) min_idx64) (of_int bucket_size))) in
let new_count = bucket_count.(bucket) + count in
bucket_count.(bucket) <- new_count;
max_val := max !max_val new_count) tbl;
Expand All @@ -1717,9 +1721,8 @@ module Test = struct
" num: %d, avg: %.2f, stddev: %.2f, median %d, min %d, max %d\n"
!num !avg stddev !median min_idx max_idx;
let indwidth =
max (String.length (Printf.sprintf "%d" min_idx))
(max (String.length (Printf.sprintf "%d" max_idx))
(String.length (Printf.sprintf "%d" (min_idx + bucket_size * hist_size)))) in
let str_width i = String.length (Printf.sprintf "%d" i) in
List.map str_width [min_idx; max_idx; min_idx + bucket_size * hist_size] |> List.fold_left max min_int in
let labwidth = if bucket_size=1 then indwidth else 2+2*indwidth in
for i = 0 to hist_size - 1 do
let i' = min_idx + i * bucket_size in
Expand Down
1 change: 0 additions & 1 deletion src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
(name qcheck)
(public_name qcheck)
(wrapped false)
(optional)
(modules QCheck_runner)
(synopsis "compatibility library for qcheck")
(libraries qcheck-core qcheck-core.runner qcheck-ounit))
Expand Down
1 change: 0 additions & 1 deletion src/ounit/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
(library
(name qcheck_ounit)
(public_name qcheck-ounit)
(optional)
(wrapped false)
(libraries unix bytes qcheck-core qcheck-core.runner ounit2)
(flags :standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string)
Expand Down
Loading