Module Expect_test_helpers_base
module CR : sig ... endmodule Sexp_style : sig ... endval hide_positions_in_string : Base.string -> Base.stringhide_positions_in_stringdoes line-based regexp matching to replace line numbers and column numbers that appear in source-code positions with constant textLINEandCOL. This can be useful in making displayed test output less fragile.
val sexp_to_string : ?hide_positions:Base.bool -> Base.Sexp.t -> Base.stringRenders an s-expression as a string. With
~hide_positions:true, patterns in the string that match OCaml-style file positions are modified to hide the line number, column number, and character positions, to make output less fragile.
val print_s : ?hide_positions:Base.bool -> Base.Sexp.t -> Base.unitFor printing an s-expression to stdout.
hide_positionsworks as insexp_to_string.
val print_cr : ?cr:CR.t -> ?hide_positions:Base.bool -> Base.Source_code_position.t -> Base.Sexp.t -> Base.unitprint_cr here messageprints aCR require-failed, which will appear in expect-test output. The CR will appear in the feature owner'sfe todo, thus preventing release of the feature.print_cris an expect-test-friendly version ofassert false. It works with the normal expect-test workflow because it does not raise, and it prevents mistakenly releasing features that violate a required property. There is no need to 'X' aCR require-failed; simply fix the property that triggered theprint_crand re-run the test to restore the empty output.
val require : ?cr:CR.t -> ?hide_positions:Base.bool -> ?if_false_then_print_s:Base.Sexp.t Base.Lazy.t -> Base.Source_code_position.t -> Base.bool -> Base.unitrequire here boolis a no-op ifbool = true, but if not, prints aCR require-failedsimilarly toprint_cr, with a message determined by theif_false_then_print_sargument, if any.if_false_then_print_sis useful for including information that may help debug the problem, but that would otherwise be too voluminous.if_false_then_print_sis lazy to avoid construction of the sexp except when needed.
val require_equal : ?cr:CR.t -> ?hide_positions:Base.bool -> ?if_false_then_print_s:Base.Sexp.t Base.Lazy.t -> ?message:Base.string -> Base.Source_code_position.t -> (module With_equal with type t = 'a) -> 'a -> 'a -> Base.unitrequire_equalcompares its two arguments using the equality predicate of the provided module. If the comparison fails, prints a message that renders the arguments as sexps.
val require_compare_equal : ?cr:CR.t -> ?hide_positions:Base.bool -> ?message:Base.string -> Base.Source_code_position.t -> (module With_compare with type t = 'a) -> 'a -> 'a -> Base.unitLike
require_equal, but derives an equality predicate from a comparison function.
val require_sets_are_equal : ?cr:CR.t -> ?hide_positions:Base.bool -> ?names:(Base.string * Base.string) -> Base.Source_code_position.t -> (module Set with type t = 'a) -> 'a -> 'a -> Base.unitLike
require_equal, but when equality fails produces a message including sexps of bothSet.diff first secondandSet.diff second firstto aid in debugging.
val show_raise : ?hide_positions:Base.bool -> ?show_backtrace:Base.bool -> (Base.unit -> _) -> Base.unitshow_raisecallsf ()and prints the exception that it raises, or, if it doesn't raise, printsdid not raise.show_raiseignores the result offso that one doesn't have to put anignoreinside the body of anfthat is expected to raise.~hide_positions:trueoperates as inprint_s, to make output less fragile. Using~show_backtrace:truewill result in a CR in the expectation, but it's still available here as it is still valuable when initially writing tests and debugging.
val require_does_not_raise : ?cr:CR.t -> ?hide_positions:Base.bool -> ?show_backtrace:Base.bool -> Base.Source_code_position.t -> (Base.unit -> Base.unit) -> Base.unitrequire_does_not_raiseis likeshow_raise, but does not print anything if the function does not raise, and prints a CR along with the exception if it does raise. Unlike forshow_raise, the supplied function is required to returnunitto avoid mistakes like incomplete partial application that silently would not raise, but for the wrong reason.
val require_does_raise : ?cr:CR.t -> ?hide_positions:Base.bool -> ?show_backtrace:Base.bool -> Base.Source_code_position.t -> (Base.unit -> _) -> Base.unitrequire_does_raiseis likeshow_raise, but additionally prints a CR if the function does not raise.
val quickcheck : Base.Source_code_position.t -> ?cr:CR.t -> ?hide_positions:Base.bool -> ?seed:Expect_test_helpers_base__.Expect_test_helpers_base_intf.Quickcheck.Test.Config.Seed.t -> ?sizes:Base.int Base.Sequence.t -> ?trials:Base.int -> ?shrinker:'a Expect_test_helpers_base__.Expect_test_helpers_base_intf.Quickcheck.Shrinker.t -> ?shrink_attempts:Base.int -> ?examples:'a Base.list -> sexp_of:('a -> Base.Sexp.t) -> f:('a -> Base.unit) -> 'a Expect_test_helpers_base__.Expect_test_helpers_base_intf.Quickcheck.Generator.t -> Base.unitquickcheckis similar toBase_quickcheck.Test.run. It stops after the first iteration that raises or prints a CR, as detected byon_print_cr.
val sexp_style : Sexp_style.t Base.refsexp_styledetermines the sexp format used bysexp_to_string,print_s, and other functions in this module. Defaults toSexp_style.default_pretty.
val on_print_cr : (Base.string -> Base.unit) Base.refon_print_crdetermines the behavior of all functions above that print CRs, such asprint_crandrequire. The rendered string form of the CR is passed to!on_print_cr. The default value isprint_endline; this can be overridden to replace or extend the default behavior. For example, some testing harnesses may choose to abort a series of tests after the first CR is printed.