Module Expect_test_matcher.Cst
module Line : sig ... endtype 'a single_line={leading_blanks : Base.string;regexp: "
\t*"trailing_spaces : Base.string;regexp: "
\t\n*"orig : Base.string;regexp: "
^ \t\n(^\n*^ \t\n)?"data : 'a;}Single line represent
%expectnodes with data on the first line but not on the subsequent ones.For instance:
[%expect " blah "]; [%expect {| blah |}]
val sexp_of_single_line : ('a -> Ppx_sexp_conv_lib.Sexp.t) -> 'a single_line -> Ppx_sexp_conv_lib.Sexp.tval compare_single_line : ('a -> 'a -> Base.int) -> 'a single_line -> 'a single_line -> Base.int
type 'a multi_lines={leading_spaces : Base.string;regexp: "\(
\t*\n\)*"trailing_spaces : Base.string;regexp: "
\t*" or "\(\n\t*\)*"indentation : Base.string;regexp: "
\t*"lines : 'a Line.t Base.list;regexp: not_blank (.* not_blank)?
}Any
%expectnode with one or more newlines and at least one non-blank line.This also include the case with exactly one non-blank line such as:
[%expect {| blah |}]This is to preserve this formatting in case the correction is multi-line.
leading_spacescontains everything until the first non-blank line, whiletrailing_spacesis either:- trailing blanks on the last line if of the form:
[%expect {| abc def |}]- all trailing spaces from the newline character (inclusive) on the last non-blank line to the end if of the form:
[%expect {| abc def |}]
val sexp_of_multi_lines : ('a -> Ppx_sexp_conv_lib.Sexp.t) -> 'a multi_lines -> Ppx_sexp_conv_lib.Sexp.tval compare_multi_lines : ('a -> 'a -> Base.int) -> 'a multi_lines -> 'a multi_lines -> Base.int
type 'a t=|Empty of Base.stringregexp: "
\t\n*"|Single_line of 'a single_line|Multi_lines of 'a multi_lines
val sexp_of_t : ('a -> Ppx_sexp_conv_lib.Sexp.t) -> 'a t -> Ppx_sexp_conv_lib.Sexp.tval compare : ('a -> 'a -> Base.int) -> 'a t -> 'a t -> Base.int
val invariant : ('a -> Base.unit) -> 'a t -> Base.unitval empty : 'a tval map : 'a t -> f:(Base.string -> 'a -> 'b) -> 'b tval data : 'a t -> blank:'a -> 'a Base.listval strip : 'a t -> 'a tval to_string : _ t -> Base.stringval to_lines : 'a t -> 'a Line.t Base.listFor single line expectation, leading blanks and trailing spaces are dropped.
val trim_lines : 'a Line.t Base.list -> 'a Line.t Base.listRemove blank lines at the beginning and end of the list.
val reconcile : 'a t -> lines:'a Line.t Base.list -> default_indentation:Base.int -> pad_single_line:Base.bool -> 'a tGiven a contents
tand a list oflines, try to produce a new contents containinglinesbut with the same formating ast.default_indentationis the indentation to use in case we ignoret's indentation (for instance iftisSingle_lineorEmpty).
val extract_indentation : 'a Line.t Base.list -> Base.string * 'a Line.t Base.listCompuute the longest indentation of a list of lines and trim it from every line. It returns the found indentation and the list of trimmed lines.
val stripped_original_lines : _ t -> Base.string Base.listAll the
.origfields ofLine.torsingle_linevalues, using""for blank lines.