37 lines
1.2 KiB
Diff
37 lines
1.2 KiB
Diff
|
From 99a5f108681271f50f31fe3988db0f94b5779c2b Mon Sep 17 00:00:00 2001
|
||
|
From: Jan Midtgaard <jmid@mmmi.sdu.dk>
|
||
|
Date: Thu, 12 Nov 2020 12:43:23 +0100
|
||
|
Subject: [PATCH 1/2] Fixes distribution and min_int issues
|
||
|
|
||
|
---
|
||
|
src/core/QCheck.ml | 6 +++---
|
||
|
1 file changed, 3 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/src/core/QCheck.ml b/src/core/QCheck.ml
|
||
|
index 5a3a3e6..67d6e3a 100644
|
||
|
--- a/src/core/QCheck.ml
|
||
|
+++ b/src/core/QCheck.ml
|
||
|
@@ -162,7 +162,7 @@ module Gen = struct
|
||
|
else fun st -> let r = pint st in r mod (n + 1)
|
||
|
let int_range a b =
|
||
|
if b < a then invalid_arg "Gen.int_range";
|
||
|
- if a >= 0 || b <= 0 then (
|
||
|
+ if a >= 0 || b < 0 then (
|
||
|
(* range smaller than max_int *)
|
||
|
assert (b-a >= 0);
|
||
|
fun st -> a + (int_bound (b-a) st)
|
||
|
@@ -171,8 +171,8 @@ module Gen = struct
|
||
|
choose the itv wrt to their size ratio *)
|
||
|
fun st ->
|
||
|
let f_a = float_of_int a in
|
||
|
- let ratio = (-.f_a) /. (float_of_int b -. f_a) in
|
||
|
- if Random.float 1. < ratio then - (int_bound (abs a) st)
|
||
|
+ let ratio = (-.f_a) /. (1. +. float_of_int b -. f_a) in
|
||
|
+ if Random.State.float st 1. <= ratio then - (Gen.int_bound (- (a+1)) st) - 1
|
||
|
else int_bound b st
|
||
|
)
|
||
|
|
||
|
--
|
||
|
2.28.0
|
||
|
|