From 762441d41d368c6324f00f6a6c958aa8d035299f Mon Sep 17 00:00:00 2001 From: Jan Midtgaard Date: Thu, 19 Dec 2024 19:48:24 +0100 Subject: [PATCH] Avoid long Lin shrinking by generating small Dynarray int elements --- src/dynarray/lin_tests.ml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/dynarray/lin_tests.ml b/src/dynarray/lin_tests.ml index f72c84d3..69d5d194 100644 --- a/src/dynarray/lin_tests.ml +++ b/src/dynarray/lin_tests.ml @@ -1,23 +1,21 @@ module Dynarray_api = struct type t = int Dynarray.t - let init () = Dynarray.make 1024 0xcafe - let cleanup _ = () + open Lin type elem = int [@@warning "-34"] - - let elem = Lin.int + let elem = nat_small + let int = nat_small let get_check a i = let v = Dynarray.get a i in if not (Obj.is_int (Obj.repr v)) then (Printf.eprintf "dummy found!\n%!"; exit 1) else v let api = - let open Lin in (*let int_not_too_big = int_bound 2048 in*) - [ val_ "get_check" get_check (t @-> nat_small @-> returning_or_exc elem); - val_ "set" Dynarray.set (t @-> nat_small @-> elem @-> returning_or_exc unit); + [ val_ "get_check" get_check (t @-> int @-> returning_or_exc elem); + val_ "set" Dynarray.set (t @-> int @-> elem @-> returning_or_exc unit); val_ "length" Dynarray.length (t @-> returning int); val_freq 3 "add_last" Dynarray.add_last (t @-> elem @-> returning_or_exc unit); val_ "append_seq" Dynarray.append_seq (t @-> seq elem @-> returning_or_exc unit); @@ -25,11 +23,11 @@ module Dynarray_api = struct val_ "pop_last" Dynarray.pop_last (t @-> returning_or_exc elem); val_freq 2 "remove_last" Dynarray.remove_last (t @-> returning_or_exc unit); val_ "clear" Dynarray.clear (t @-> returning_or_exc unit); - val_ "truncate" Dynarray.truncate (t @-> nat_small @-> returning_or_exc unit); - val_ "ensure_capacity" Dynarray.ensure_capacity (t @-> nat_small @-> returning_or_exc unit); + val_ "truncate" Dynarray.truncate (t @-> int @-> returning_or_exc unit); + val_ "ensure_capacity" Dynarray.ensure_capacity (t @-> int @-> returning_or_exc unit); val_ "fit_capacity" Dynarray.fit_capacity (t @-> returning_or_exc unit); (*val_ "blit" Dynarray.blit (t @-> int_not_too_big @-> t @-> int_not_too_big @-> int_not_too_big @-> returning_or_exc unit);*) - val_freq 2 "set_capacity" Dynarray.set_capacity (t @-> nat_small @-> returning_or_exc unit); + val_freq 2 "set_capacity" Dynarray.set_capacity (t @-> int @-> returning_or_exc unit); val_ "reset" Dynarray.reset (t @-> returning_or_exc unit); ] end