mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
add a few tests
This commit is contained in:
parent
a4f0e17799
commit
425dba1e25
1 changed files with 14 additions and 0 deletions
|
|
@ -81,6 +81,11 @@ let init ~kind ~f n =
|
|||
done;
|
||||
a
|
||||
|
||||
(*$T
|
||||
let a = init ~kind:Bigarray.int 10 ~f:(fun x->x) in \
|
||||
CCList.(0 -- 9) |> List.for_all (fun i -> get a i = i)
|
||||
*)
|
||||
|
||||
let of_bigarray a = a
|
||||
let to_bigarray a = a
|
||||
|
||||
|
|
@ -96,6 +101,10 @@ let copy a =
|
|||
|
||||
let length a = A.dim a
|
||||
|
||||
(*$T
|
||||
length (make_int 42) = 42
|
||||
*)
|
||||
|
||||
let set = A.set
|
||||
|
||||
let get = A.get
|
||||
|
|
@ -127,6 +136,11 @@ let exists ~f a =
|
|||
false
|
||||
with LocalExit -> true
|
||||
|
||||
(*$T
|
||||
init ~kind:Bigarray.int 10 ~f:(fun x->x) |> for_all ~f:(fun x -> x<10)
|
||||
init ~kind:Bigarray.int 10 ~f:(fun x->x) |> exists ~f:(fun x -> x=5)
|
||||
*)
|
||||
|
||||
let iteri ~f a =
|
||||
for i = 0 to A.dim a - 1 do
|
||||
f i (A.unsafe_get a i)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue