mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
fix: add shims for CCArray
This commit is contained in:
parent
f71472ad08
commit
7ff5aa0d18
4 changed files with 20 additions and 11 deletions
|
|
@ -18,7 +18,7 @@ type 'a printer = Format.formatter -> 'a -> unit
|
|||
|
||||
(** {2 Arrays} *)
|
||||
|
||||
include Array
|
||||
include CCShimsArray_
|
||||
|
||||
type 'a t = 'a array
|
||||
|
||||
|
|
@ -148,14 +148,14 @@ let sorted cmp a =
|
|||
b
|
||||
|
||||
(*$= & ~cmp:(=) ~printer:Q.Print.(array int)
|
||||
[||] (sorted Pervasives.compare [||])
|
||||
[|0;1;2;3;4|] (sorted Pervasives.compare [|3;2;1;4;0|])
|
||||
[||] (sorted Stdlib.compare [||])
|
||||
[|0;1;2;3;4|] (sorted Stdlib.compare [|3;2;1;4;0|])
|
||||
*)
|
||||
|
||||
(*$Q
|
||||
Q.(array int) (fun a -> \
|
||||
let b = Array.copy a in \
|
||||
Array.sort Pervasives.compare b; b = sorted Pervasives.compare a)
|
||||
Array.sort Stdlib.compare b; b = sorted Stdlib.compare a)
|
||||
*)
|
||||
|
||||
let sort_indices cmp a =
|
||||
|
|
@ -165,8 +165,8 @@ let sort_indices cmp a =
|
|||
b
|
||||
|
||||
(*$= & ~cmp:(=) ~printer:Q.Print.(array int)
|
||||
[||] (sort_indices Pervasives.compare [||])
|
||||
[|4;2;1;0;3|] (sort_indices Pervasives.compare [|"d";"c";"b";"e";"a"|])
|
||||
[||] (sort_indices Stdlib.compare [||])
|
||||
[|4;2;1;0;3|] (sort_indices Stdlib.compare [|"d";"c";"b";"e";"a"|])
|
||||
*)
|
||||
|
||||
(*$Q
|
||||
|
|
@ -179,8 +179,8 @@ let sort_ranking cmp a =
|
|||
sort_indices compare (sort_indices cmp a)
|
||||
|
||||
(*$= & ~cmp:(=) ~printer:Q.Print.(array int)
|
||||
[||] (sort_ranking Pervasives.compare [||])
|
||||
[|3;2;1;4;0|] (sort_ranking Pervasives.compare [|"d";"c";"b";"e";"a"|])
|
||||
[||] (sort_ranking Stdlib.compare [||])
|
||||
[|3;2;1;4;0|] (sort_ranking Stdlib.compare [|"d";"c";"b";"e";"a"|])
|
||||
*)
|
||||
|
||||
(*$Q
|
||||
|
|
@ -670,9 +670,11 @@ let sort_generic (type arr)(type elt)
|
|||
|
||||
(*$inject
|
||||
module IA = struct
|
||||
let get = Array.get
|
||||
let set = Array.set
|
||||
let length = Array.length
|
||||
type elt = int
|
||||
type t = int array
|
||||
include Array
|
||||
end
|
||||
|
||||
let gen_arr = Q.Gen.(array_size (1--100) small_int)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ type 'a printer = Format.formatter -> 'a -> unit
|
|||
external make_float : int -> float array = "caml_make_float_vect" (* compat *)
|
||||
(**/**)
|
||||
|
||||
include module type of Array
|
||||
include module type of CCShimsArray_
|
||||
|
||||
type 'a t = 'a array
|
||||
(** The type for arrays *)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
(libraries dune.configurator))
|
||||
|
||||
(rule
|
||||
(targets CCShims_.ml CCShimsList_.ml CCShimsFormat_.ml)
|
||||
(targets CCShims_.ml CCShimsList_.ml CCShimsArray_.ml CCShimsFormat_.ml)
|
||||
(deps ./mkshims.exe)
|
||||
(action (run ./mkshims.exe)))
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,12 @@ let shims_list_pre_408 = "
|
|||
"
|
||||
let shims_list_post_408 = "include List"
|
||||
|
||||
let shims_array_pre_408 = "
|
||||
include Array
|
||||
type 'a t = 'a array
|
||||
"
|
||||
let shims_array_post_408 = "include Array"
|
||||
|
||||
let write_file f s =
|
||||
let out = open_out f in
|
||||
output_string out s; flush out; close_out out
|
||||
|
|
@ -51,5 +57,6 @@ let () =
|
|||
let major, minor = Scanf.sscanf version "%u.%u" (fun maj min -> maj, min) in
|
||||
write_file "CCShims_.ml" (if (major, minor) >= (4,8) then shims_post_408 else shims_pre_408);
|
||||
write_file "CCShimsList_.ml" (if (major, minor) >= (4,8) then shims_list_post_408 else shims_list_pre_408);
|
||||
write_file "CCShimsArray_.ml" (if (major, minor) >= (4,8) then shims_array_post_408 else shims_array_pre_408);
|
||||
write_file "CCShimsFormat_.ml" (if (major, minor) >= (4,8) then shims_fmt_post_408 else shims_fmt_pre_408);
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue