package ppx_expect

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file expectation.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
open! Base
open Import
open Ppx_compare_lib.Builtin
open Sexplib0.Sexp_conv

module Body = struct
  type 'a t =
    | Exact of string
    | Output
    | Pretty of 'a
    | Unreachable
  [@@deriving_inline sexp_of, compare, equal]

  let _ = fun (_ : 'a t) -> ()

  let sexp_of_t : 'a. ('a -> Sexplib0.Sexp.t) -> 'a t -> Sexplib0.Sexp.t =
    fun (type a__006_) : ((a__006_ -> Sexplib0.Sexp.t) -> a__006_ t -> Sexplib0.Sexp.t) ->
    fun _of_a__001_ -> function
      | Exact arg0__002_ ->
        let res0__003_ = sexp_of_string arg0__002_ in
        Sexplib0.Sexp.List [ Sexplib0.Sexp.Atom "Exact"; res0__003_ ]
      | Output -> Sexplib0.Sexp.Atom "Output"
      | Pretty arg0__004_ ->
        let res0__005_ = _of_a__001_ arg0__004_ in
        Sexplib0.Sexp.List [ Sexplib0.Sexp.Atom "Pretty"; res0__005_ ]
      | Unreachable -> Sexplib0.Sexp.Atom "Unreachable"
  ;;

  let _ = sexp_of_t

  let compare : 'a. ('a -> 'a -> int) -> 'a t -> 'a t -> int =
    fun _cmp__a a__007_ b__008_ ->
    if Stdlib.( == ) a__007_ b__008_
    then 0
    else (
      match a__007_, b__008_ with
      | Exact _a__009_, Exact _b__010_ -> compare_string _a__009_ _b__010_
      | Exact _, _ -> -1
      | _, Exact _ -> 1
      | Output, Output -> 0
      | Output, _ -> -1
      | _, Output -> 1
      | Pretty _a__011_, Pretty _b__012_ -> _cmp__a _a__011_ _b__012_
      | Pretty _, _ -> -1
      | _, Pretty _ -> 1
      | Unreachable, Unreachable -> 0)
  ;;

  let _ = compare

  let equal : 'a. ('a -> 'a -> bool) -> 'a t -> 'a t -> bool =
    fun _cmp__a a__013_ b__014_ ->
    if Stdlib.( == ) a__013_ b__014_
    then true
    else (
      match a__013_, b__014_ with
      | Exact _a__015_, Exact _b__016_ -> equal_string _a__015_ _b__016_
      | Exact _, _ -> false
      | _, Exact _ -> false
      | Output, Output -> true
      | Output, _ -> false
      | _, Output -> false
      | Pretty _a__017_, Pretty _b__018_ -> _cmp__a _a__017_ _b__018_
      | Pretty _, _ -> false
      | _, Pretty _ -> false
      | Unreachable, Unreachable -> true)
  ;;

  let _ = equal

  [@@@end]

  let map_pretty t ~f =
    match t with
    | (Exact _ | Output | Unreachable) as t -> t
    | Pretty x -> Pretty (f x)
  ;;
end

type 'a t =
  { tag : string option
  ; body : 'a Body.t
  ; extid_location : File.Location.t
  ; body_location : File.Location.t
  }
[@@deriving_inline sexp_of, compare, equal]

let _ = fun (_ : 'a t) -> ()

let sexp_of_t : 'a. ('a -> Sexplib0.Sexp.t) -> 'a t -> Sexplib0.Sexp.t =
  fun _of_a__019_
    { tag = tag__021_
    ; body = body__023_
    ; extid_location = extid_location__025_
    ; body_location = body_location__027_
    } ->
    let bnds__020_ = ([] : _ Stdlib.List.t) in
    let bnds__020_ =
      let arg__028_ = File.Location.sexp_of_t body_location__027_ in
      (Sexplib0.Sexp.List [ Sexplib0.Sexp.Atom "body_location"; arg__028_ ] :: bnds__020_
       : _ Stdlib.List.t)
    in
    let bnds__020_ =
      let arg__026_ = File.Location.sexp_of_t extid_location__025_ in
      (Sexplib0.Sexp.List [ Sexplib0.Sexp.Atom "extid_location"; arg__026_ ] :: bnds__020_
       : _ Stdlib.List.t)
    in
    let bnds__020_ =
      let arg__024_ = Body.sexp_of_t _of_a__019_ body__023_ in
      (Sexplib0.Sexp.List [ Sexplib0.Sexp.Atom "body"; arg__024_ ] :: bnds__020_
       : _ Stdlib.List.t)
    in
    let bnds__020_ =
      let arg__022_ = sexp_of_option sexp_of_string tag__021_ in
      (Sexplib0.Sexp.List [ Sexplib0.Sexp.Atom "tag"; arg__022_ ] :: bnds__020_
       : _ Stdlib.List.t)
    in
    Sexplib0.Sexp.List bnds__020_
;;

let _ = sexp_of_t

let compare : 'a. ('a -> 'a -> int) -> 'a t -> 'a t -> int =
  fun _cmp__a a__029_ b__030_ ->
  if Stdlib.( == ) a__029_ b__030_
  then 0
  else (
    match compare_option compare_string a__029_.tag b__030_.tag with
    | 0 ->
      (match Body.compare _cmp__a a__029_.body b__030_.body with
       | 0 ->
         (match File.Location.compare a__029_.extid_location b__030_.extid_location with
          | 0 -> File.Location.compare a__029_.body_location b__030_.body_location
          | n -> n)
       | n -> n)
    | n -> n)
;;

let _ = compare

let equal : 'a. ('a -> 'a -> bool) -> 'a t -> 'a t -> bool =
  fun _cmp__a a__035_ b__036_ ->
  if Stdlib.( == ) a__035_ b__036_
  then true
  else
    Stdlib.( && )
      (equal_option equal_string a__035_.tag b__036_.tag)
      (Stdlib.( && )
         (Body.equal _cmp__a a__035_.body b__036_.body)
         (Stdlib.( && )
            (File.Location.equal a__035_.extid_location b__036_.extid_location)
            (File.Location.equal a__035_.body_location b__036_.body_location)))
;;

let _ = equal

[@@@end]

module Raw = struct
  type nonrec t = string t [@@deriving_inline sexp_of, compare]

  let _ = fun (_ : t) -> ()
  let sexp_of_t = (fun x__041_ -> sexp_of_t sexp_of_string x__041_ : t -> Sexplib0.Sexp.t)
  let _ = sexp_of_t

  let compare =
    (fun a__042_ b__043_ -> compare compare_string a__042_ b__043_ : t -> t -> int)
  ;;

  let _ = compare

  [@@@end]
end

let map_pretty t ~f = { t with body = Body.map_pretty t.body ~f }
OCaml

Innovation. Community. Security.