Skip to content

Commit

Permalink
Avoid long Lin shrinking by generating small Dynarray int elements
Browse files Browse the repository at this point in the history
  • Loading branch information
jmid committed Dec 19, 2024
1 parent 7574c76 commit 762441d
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/dynarray/lin_tests.ml
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
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);
val_ "get_last" Dynarray.get_last (t @-> returning_or_exc elem);
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
Expand Down

0 comments on commit 762441d

Please sign in to comment.