Skip to content

Commit b37c72c

Browse files
authored
Merge pull request #401 from jmid/cleanup-deprecated
Remove deprecated bindings for 1.0 release
2 parents 29fae9d + 0bf9f04 commit b37c72c

File tree

5 files changed

+50
-779
lines changed

5 files changed

+50
-779
lines changed

CHANGELOG.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,49 @@
22

33
## NEXT RELEASE (202?-??-??)
44

5-
- ...
5+
- Remove deprecated generator bindings:
6+
- `QCheck.Gen`:
7+
- `big_nat` `neg_int` `pint` `small_nat` `small_int` `small_signed_int` `int_pos_corners`, `int_corners`
8+
- `ui32` `ui64`
9+
- `pfloat` `nfloat`
10+
- `opt`
11+
- `string_readable` `small_string`
12+
- `small_list` `list_repeat`
13+
- `array_repeat` `small_array`
14+
- `oneofl` `oneofa`
15+
- `frequency` `frequencyl` `frequencya`
16+
- `shuffle_a` `shuffle_l` `shuffle_w_l`
17+
- `flatten_l` `flatten_a` `flatten_opt` `flatten_res`
18+
- `QCheck.arbitrary`:
19+
- `small_nat` `small_int` `small_signed_int` `pos_int` `neg_int` - `small_int_corners`
20+
- `pos_float` `neg_float`
21+
- `printable_char` `numeral_char`
22+
- `string_gen_of_size` `string_gen` `small_string` `string_of_size`
23+
`printable_string` `printable_string_of_size` `string_printable_of_size` `small_printable_string` `string_small_printable`
24+
`numeral_string` `string_numeral` `numeral_string_of_size` `string_numeral_of_size`
25+
- `bytes_gen_of_size` `bytes_of_size`
26+
- `small_list` `list_of_size`
27+
- `array_of_size`
28+
- `choose` `oneofl` `oneofa`
29+
- `frequency` `frequencyl` `frequencya`
30+
- `QCheck2.Gen`:
31+
- `pint` `small_nat` `big_nat` `neg_int` `small_int` `small_signed_int`
32+
`small_int_corners` `int_pos_corners` `int_corners`
33+
- `ui32` `ui64`
34+
- `pfloat` `nfloat`
35+
- `opt`
36+
- `small_string`
37+
- `small_list` `list_repeat`
38+
- `small_array` `array_repeat`
39+
- `oneofl` `oneofa`
40+
- `frequency` `frequencyl` `frequencya`
41+
- `shuffle_a` `shuffle_l` `shuffle_w_l`
42+
- `flatten_l` `flatten_a` `flatten_opt` `flatten_res`
43+
- Other removed deprecated `QCheck2` bindings:
44+
- `Print.comap`
45+
- `Shrink.int_aggressive`
46+
- `Observable.map`
47+
- `TestResult.stats` `TestResult.warnings` `TestResult.collect`
648

749

850
## 0.91 (2025-12-21)

src/core/QCheck.ml

Lines changed: 4 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,7 @@ module Gen = struct
138138

139139
let oneof l st = List.nth l (Random.State.int st (List.length l)) st
140140
let oneof_list xs st = List.nth xs (Random.State.int st (List.length xs))
141-
let oneofl = oneof_list
142141
let oneof_array xs st = Array.get xs (Random.State.int st (Array.length xs))
143-
let oneofa = oneof_array
144142

145143
let oneof_list_weighted l st =
146144
let sums = sum_int (List.map fst l) in
@@ -151,21 +149,14 @@ module Gen = struct
151149
in
152150
aux 0 l
153151

154-
let frequencyl = oneof_list_weighted
155-
156152
let oneof_array_weighted a = oneof_list_weighted (Array.to_list a)
157153

158-
let frequencya = oneof_array_weighted
159-
160154
let oneof_weighted l st = oneof_list_weighted l st st
161155

162-
let frequency = oneof_weighted
163-
164156
let int_pos_small st =
165157
let p = RS.float st 1. in
166158
if p < 0.75 then RS.int st 10 else RS.int st 100
167159
let nat_small = int_pos_small
168-
let small_nat = int_pos_small
169160

170161
(* natural number generator *)
171162
let nat st =
@@ -177,11 +168,6 @@ module Gen = struct
177168

178169
let int_pos_mid = nat
179170

180-
let big_nat st =
181-
let p = RS.float st 1. in
182-
if p < 0.75 then nat st
183-
else RS.int st 1_000_000
184-
185171
let unit _st = ()
186172

187173
let bool st = RS.bool st
@@ -200,9 +186,6 @@ module Gen = struct
200186
let float_pos st = abs_float (float st)
201187
let float_neg st = -.(float_pos st)
202188

203-
let pfloat = float_pos
204-
let nfloat = float_neg
205-
206189
let float_bound_inclusive bound st = RS.float st bound
207190

208191
let float_bound_exclusive bound st =
@@ -225,15 +208,11 @@ module Gen = struct
225208

226209
let exponential = float_exp
227210

228-
let neg_int st = -(nat st)
229-
230211
let option ?(ratio = 0.85) f st =
231212
let p = RS.float st 1. in
232213
if p < (1.0 -. ratio) then None
233214
else Some (f st)
234215

235-
let opt = option
236-
237216
let result ?(ratio = 0.75) vg eg st =
238217
let p = RS.float st 1. in
239218
if p < (1.0 -. ratio)
@@ -256,8 +235,6 @@ module Gen = struct
256235
let right = RS.bits st in
257236
left lor middle lor right
258237

259-
let pint = int_pos
260-
261238
let int_neg st = -(int_pos st)-1
262239

263240
let int st = if RS.bool st then - (int_pos st) - 1 else int_pos st
@@ -284,17 +261,11 @@ module Gen = struct
284261

285262
let (--) = int_range
286263

287-
(* NOTE: we keep this alias to not break code that uses [small_int]
288-
for sizes of strings, arrays, etc. *)
289-
let small_int = small_nat
290-
291264
let int_small st =
292265
if bool st
293266
then nat_small st
294267
else - (nat_small st)
295268

296-
let small_signed_int = int_small
297-
298269
let char_range a b = map Char.chr (Char.code a -- Char.code b)
299270

300271
let random_binary_string st length =
@@ -310,9 +281,6 @@ module Gen = struct
310281
let int32 st = Int32.of_string (random_binary_string st 32)
311282
let int64 st = Int64.of_string (random_binary_string st 64)
312283

313-
let ui32 = int32
314-
let ui64 = int64
315-
316284
let list_size size gen st =
317285
foldn ~f:(fun acc _ -> (gen st)::acc) ~init:[] (size st)
318286
let list gen st = list_size nat gen st
@@ -321,12 +289,9 @@ module Gen = struct
321289
let array_size size gen st =
322290
Array.init (size st) (fun _ -> gen st)
323291
let array gen st = array_size nat gen st
324-
let array_repeat n g = array_size (return n) g
325292

326293
let flatten_list l st = List.map (fun f->f st) l
327-
let flatten_l = flatten_list
328294
let flatten_array a st = Array.map (fun f->f st) a
329-
let flatten_a = flatten_array
330295
let flatten_option o st =
331296
match o with
332297
| None -> None
@@ -356,8 +321,6 @@ module Gen = struct
356321
shuffle_a a st;
357322
Array.to_list a
358323

359-
let shuffle_l = shuffle_list
360-
361324
let shuffle_list_weighted l st =
362325
let sample (w, v) =
363326
let fl_w = float_of_int w in
@@ -366,8 +329,6 @@ module Gen = struct
366329
let samples = List.rev_map sample l in
367330
List.sort (fun (w1, _) (w2, _) -> poly_compare w1 w2) samples |> List.rev_map snd
368331

369-
let shuffle_w_l = shuffle_list_weighted
370-
371332
let range_subset ~size low high st =
372333
let range_size = high - low + 1 in
373334
if not (0 <= size && size <= range_size) then
@@ -458,14 +419,10 @@ module Gen = struct
458419
let string_of gen = string_size ~gen nat
459420
let bytes_printable = bytes_size ~gen:char_printable nat
460421
let string_printable = string_size ~gen:char_printable nat
461-
let string_readable = string_printable
462422
let bytes_small st = bytes_size nat_small st
463423
let bytes_small_of gen st = bytes_size ~gen nat_small st
464-
let small_string ?gen st = string_size ?gen nat_small st
465424
let list_small gen = list_size nat_small gen
466-
let small_list = list_small
467425
let array_small gen = array_size nat_small gen
468-
let small_array = array_small
469426
let string_small st = string_size nat_small st
470427
let string_small_of gen st = string_size ~gen nat_small st
471428

@@ -482,7 +439,6 @@ module Gen = struct
482439
let int_corners = int_pos_corners @ [min_int;-2;-1]
483440

484441
let int_small_corners () = graft_corners int_small int_corners ()
485-
let nng_corners () = graft_corners nat int_pos_corners ()
486442

487443
(* sized, fix *)
488444

@@ -1294,8 +1250,6 @@ let bool =
12941250
let float = make_scalar Gen.float
12951251
let float_pos = make_scalar Gen.float_pos
12961252
let float_neg = make_scalar Gen.float_neg
1297-
let pos_float = float_pos
1298-
let neg_float = float_neg
12991253

13001254
let float_bound_inclusive bound =
13011255
make ~small:small1 ~shrink:(Shrink.float_bound bound) ~print:Print.float (Gen.float_bound_inclusive bound)
@@ -1317,19 +1271,14 @@ let int_bound n = make_int (Gen.int_bound n)
13171271
let int_range a b = make_int (Gen.int_range a b)
13181272
let (--) = int_range
13191273
let int_pos = make_int Gen.int_pos
1320-
let pos_int = int_pos
1321-
let small_int = make_int Gen.small_int
1274+
13221275
let nat = make_int Gen.nat
13231276
let int_pos_small = make_int Gen.int_pos_small
13241277
let int_pos_mid = nat
13251278
let nat_small = int_pos_small
1326-
let small_nat = nat_small
1327-
let int_small = make_int Gen.small_signed_int
1328-
let small_signed_int = int_small
1329-
let small_int_corners () = make_int (Gen.nng_corners ())
1279+
let int_small = make_int Gen.int_small
13301280
let int_small_corners () = make_int (Gen.int_small_corners ())
13311281
let int_neg = make_int Gen.int_neg
1332-
let neg_int = make_int Gen.neg_int
13331282

13341283
let int32 =
13351284
make ~print:Print.int32 ~small:small1 ~shrink:Shrink.int32 Gen.int32
@@ -1345,23 +1294,19 @@ let char_range low high =
13451294
let char_printable =
13461295
make ~print:Print.char ~small:(small_char 'a') ~shrink:Shrink.char_printable Gen.char_printable
13471296
let printable = char_printable
1348-
let printable_char = char_printable
13491297
let char_numeral =
13501298
make ~print:Print.char ~small:(small_char '0') ~shrink:Shrink.char_numeral Gen.char_numeral
13511299
let numeral = char_numeral
1352-
let numeral_char = char_numeral
13531300

13541301
let bytes_size ?(gen = Gen.char) size =
13551302
make ~shrink:Shrink.bytes ~small:Bytes.length
13561303
~print:Print.bytes (Gen.bytes_size ~gen size)
13571304
let bytes_size_of size gen = bytes_size ~gen size
1358-
let bytes_gen_of_size size gen = bytes_size ~gen size
13591305
let bytes_of gen =
13601306
make ~shrink:Shrink.bytes ~small:Bytes.length
13611307
~print:Print.bytes (Gen.bytes_of gen)
13621308

13631309
let bytes = bytes_of Gen.char
1364-
let bytes_of_size size = bytes_size ~gen:Gen.char size
13651310
let bytes_small = bytes_size ~gen:Gen.char Gen.nat_small
13661311
let bytes_small_of gen = bytes_size ~gen Gen.nat_small
13671312
let bytes_printable =
@@ -1377,39 +1322,13 @@ let string_of gen =
13771322

13781323
let string = string_of Gen.char
13791324
let string_size ?(gen=Gen.char) size = string_size_of size gen
1380-
let string_of_size size = string_size_of size Gen.char
13811325
let string_small = string_size_of Gen.nat_small Gen.char
13821326
let string_small_of gen = string_size_of Gen.nat_small gen
1383-
let small_string = string_small
1384-
let string_gen = string_of
1385-
let string_gen_of_size = string_size_of
13861327

13871328
let string_printable =
13881329
make ~shrink:(Shrink.string ~shrink:Shrink.char_printable) ~small:String.length
13891330
~print:Print.string (Gen.string_of Gen.char_printable)
13901331

1391-
let printable_string_of_size size =
1392-
make ~shrink:(Shrink.string ~shrink:Shrink.char_printable) ~small:String.length
1393-
~print:Print.string (Gen.string_size ~gen:Gen.char_printable size)
1394-
1395-
let small_printable_string =
1396-
make ~shrink:(Shrink.string ~shrink:Shrink.char_printable) ~small:String.length
1397-
~print:Print.string (Gen.string_size ~gen:Gen.char_printable Gen.nat_small)
1398-
1399-
let numeral_string =
1400-
make ~shrink:(Shrink.string ~shrink:Shrink.char_numeral) ~small:String.length
1401-
~print:Print.string (Gen.string_of Gen.char_numeral)
1402-
1403-
let numeral_string_of_size size =
1404-
make ~shrink:(Shrink.string ~shrink:Shrink.char_numeral) ~small:String.length
1405-
~print:Print.string (Gen.string_size ~gen:Gen.char_numeral size)
1406-
1407-
let printable_string = string_printable
1408-
let string_printable_of_size = printable_string_of_size
1409-
let string_small_printable = small_printable_string
1410-
let string_numeral = numeral_string
1411-
let string_numeral_of_size = numeral_string_of_size
1412-
14131332
let list_sum_ f l = List.fold_left (fun acc x-> f x+acc) 0 l
14141333

14151334
let mk_list a gen =
@@ -1420,9 +1339,7 @@ let mk_list a gen =
14201339

14211340
let list a = mk_list a (Gen.list a.gen)
14221341
let list_size size a = mk_list a (Gen.list_size size a.gen)
1423-
let list_of_size = list_size
1424-
let list_small a = mk_list a (Gen.small_list a.gen)
1425-
let small_list = list_small
1342+
let list_small a = mk_list a (Gen.list_small a.gen)
14261343

14271344
let array_sum_ f a = Array.fold_left (fun acc x -> f x+acc) 0 a
14281345

@@ -1450,8 +1367,6 @@ let array_size size a =
14501367
?print:(_opt_map ~f:Print.array a.print)
14511368
(Gen.array_size size a.gen)
14521369

1453-
let array_of_size = array_size
1454-
14551370
let pair a b =
14561371
make
14571372
?small:(_opt_map_2 ~f:(fun f g (x,y) -> f x+g y) a.small b.small)
@@ -1551,7 +1466,7 @@ let tup9 a b c d e f g h i =
15511466
(Gen.tup9 a.gen b.gen c.gen d.gen e.gen f.gen g.gen h.gen i.gen)
15521467

15531468
let option ?ratio a =
1554-
let g = Gen.opt ?ratio a.gen
1469+
let g = Gen.option ?ratio a.gen
15551470
and shrink = _opt_map a.shrink ~f:Shrink.option
15561471
and small =
15571472
_opt_map_or a.small ~d:(function None -> 0 | Some _ -> 1)
@@ -1866,13 +1781,7 @@ let fun4 o1 o2 o3 o4 ret =
18661781

18671782
(** given a list, returns generator that picks at random from list *)
18681783
let oneof_list ?print ?small xs = make ?print ?small (Gen.oneof_list xs)
1869-
let oneofl ?print ?collect xs = make ?print ?collect (Gen.oneof_list xs)
18701784
let oneof_array ?print ?small xs = make ?print ?small (Gen.oneof_array xs)
1871-
let oneofa ?print ?collect xs = make ?print ?collect (Gen.oneof_array xs)
1872-
1873-
(** Given a list of generators, returns generator that randomly uses one of the generators
1874-
from the list *)
1875-
let choose l = oneof l
18761785

18771786
(** Generator that always returns given value *)
18781787
let always ?print x =
@@ -1888,12 +1797,6 @@ let oneof_weighted ?print ?small ?shrink l =
18881797
let gens = List.map (fun (x,y) -> x, y.gen) l in
18891798
make ?print ?small ?shrink (Gen.oneof_weighted gens)
18901799

1891-
let frequency ?print ?small ?shrink ?collect l =
1892-
let arb = oneof_weighted ?print ?small ?shrink l in
1893-
match collect with
1894-
| None -> arb
1895-
| Some c -> set_collect c arb
1896-
18971800
(** Given list of [(frequency,value)] pairs, returns value with probability proportional
18981801
to given frequency *)
18991802
let oneof_list_weighted ?print ?small l = make ?print ?small (Gen.oneof_list_weighted l)

0 commit comments

Comments
 (0)