-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #463 from OlivierNicole/dynarray-tests
Dynarray tests
- Loading branch information
Showing
4 changed files
with
731 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
;; Tests of the Dynarray library - added in 5.2 | ||
|
||
(test | ||
(name lin_tests) | ||
(modules lin_tests) | ||
(package multicoretests) | ||
(libraries qcheck-lin.domain) | ||
(action (run %{test} --verbose)) | ||
(enabled_if (>= %{ocaml_version} 5.2)) | ||
) | ||
|
||
(test | ||
(name stm_tests) | ||
(modules stm_tests) | ||
(package multicoretests) | ||
(libraries qcheck-stm.sequential qcheck-stm.domain) | ||
(action (run %{test} --verbose)) | ||
(enabled_if (>= %{ocaml_version} 5.2)) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
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 = 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 int_not_too_big = int_bound 2048 in*) | ||
[ 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 @-> 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 @-> int @-> returning_or_exc unit); | ||
val_ "reset" Dynarray.reset (t @-> returning_or_exc unit); | ||
] | ||
end | ||
|
||
module DAT = Lin_domain.Make (Dynarray_api) | ||
|
||
let () = | ||
QCheck_base_runner.run_tests_main | ||
[ DAT.neg_lin_test ~count:1000 ~name:"Lin Dynarray test with Domain"; | ||
DAT.stress_test ~count:1000 ~name:"Lin Dynarray stress test with Domain"; | ||
] |
Oops, something went wrong.