Source file test_blit_intf.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
(** Produce unit tests for blittable values. *)

open! Base
open! Blit

module type Elt = sig
  type t

  val equal : t -> t -> bool

  (** [of_bool] is used to generate two distinct values of type [t], used in unit tests.
      It is required that [of_bool false <> of_bool true]. *)
  val of_bool : bool -> t
end

module type Elt1 = sig
  type 'a t

  val equal : bool t -> bool t -> bool
  val of_bool : bool -> bool t
end

module type Sequence = sig
  type t
  type elt

  val create : len:int -> t
  val length : t -> int
  val get : t -> int -> elt
  val set : t -> int -> elt -> unit
end

type 'a poly = 'a

module type Sequence1 = sig
  type 'a t

  (** [Make1*] guarantees to only call [create_like ~len t] with [len > 0] if [length t >
      0]. *)
  val length : _ t -> int

  (** [create_bool], [get], and [set] are just used for unit tests.  [z] is needed for
      [Flat_tuple_array], [elt] is needed for [Option_array]. *)
  type 'a z

  type 'a elt

  val create_bool : len:int -> bool z t
  val get : 'a z t -> int -> 'a elt
  val set : 'a z t -> int -> 'a elt -> unit
end

module type Test_blit = sig
  module type Elt = Elt
  module type Elt1 = Elt1
  module type Sequence = Sequence
  module type Sequence1 = Sequence1

  module Test
    (Elt : Elt)
    (Sequence : Sequence with type elt := Elt.t)
    (Tested : S with type t := Sequence.t) : sig end

  module Test_distinct
    (Elt : Elt)
    (Src : Sequence with type elt := Elt.t)
    (Dst : Sequence with type elt := Elt.t)
    (Tested : S_distinct with type src := Src.t with type dst := Dst.t) : sig end

  module Test1
    (Sequence : Sequence1 with type 'a elt := 'a poly)
    (Tested : S1 with type 'a t := 'a Sequence.t) : sig end

  module Test1_generic
    (Elt : Elt1)
    (Sequence : Sequence1 with type 'a elt := 'a Elt.t)
    (Tested : S1 with type 'a t := 'a Sequence.t) : sig end

  (** [Make_and_test] uses the [Blit.Make] functor and the [Test] functor. *)
  module Make_and_test
    (Elt : Elt) (Sequence : sig
      include Sequence with type elt := Elt.t

      val unsafe_blit : (t, t) blit
    end) : S with type t := Sequence.t

  module Make_distinct_and_test
    (Elt : Elt)
    (Src : Sequence with type elt := Elt.t) (Dst : sig
      include Sequence with type elt := Elt.t

      val unsafe_blit : (Src.t, t) blit
    end) : S_distinct with type src := Src.t with type dst := Dst.t

  module Make1_and_test (Sequence : sig
    include Blit.Sequence1
    include Sequence1 with type 'a t := 'a t with type 'a elt := 'a poly
  end) : S1 with type 'a t := 'a Sequence.t

  module Make1_generic_and_test
    (Elt : Elt1) (Sequence : sig
      include Blit.Sequence1
      include Sequence1 with type 'a t := 'a t with type 'a elt := 'a Elt.t
    end) : S1 with type 'a t := 'a Sequence.t
end