Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file expect_test_helpers_core_intf.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204open!CoremoduleAllocation_limit=structtypet=|Major_wordsofint|Minor_wordsofint[@@derivingsexp_of]endmoduletypeWith_comparable=sigtypet[@@derivingcompare,sexp_of]typekey:=tincludeComparator.Swithtypet:=t(* [Set] and [Map] submodules are here because we specifically want to test whether they
have been constructed correctly, as opposed to testing the functor that creates
them. *)moduleSet:sigtypet=(key,comparator_witness)Set.t[@@derivingsexp_of]endmoduleMap:sigtype'at=(key,'a,comparator_witness)Map.t[@@derivingsexp_of]endendmoduleComparable_satisfies_with_comparable(M:sigtypet[@@derivingsexp_of]includeComparable.Swithtypet:=tend):With_comparable=MmoduletypeWith_hashable=sigtypet[@@derivingcompare,hash,sexp_of]typekey:=t(* [Hash_set] and [Table] submodules are here because we specifically want to test
whether they have been constructed correctly, as opposed to testing the functor that
creates them. *)moduleHash_set:sigtypet=keyHash_set.t[@@derivingsexp_of]endmoduleTable:sigtype'at=(key,'a)Hashtbl.t[@@derivingsexp_of]endendmoduleHashable_satisfies_with_hashable(M:sigtypet[@@derivingsexp_of]includeHashable.Swithtypet:=tend):With_hashable=MmoduletypeWith_containers=sigtypetincludeWith_comparablewithtypet:=tincludeWith_hashablewithtypet:=tendmoduletypeExpect_test_helpers_core=sig(** Helpers for producing output inside [let%expect_test]. Designed for code using
[Core]. See also [Expect_test_helpers_base] and [Expect_test_helpers_async]. *)includemoduletypeofstructincludeExpect_test_helpers_baseendmoduletypeWith_containers=With_containersmoduletypeWith_comparable=With_comparablemoduletypeWith_hashable=With_hashable(** {3 Serialization tests} *)(** [print_and_check_stable_type] prints the bin-io digest for the given type, and the
bin-io and sexp serializations of the given values. Prints an error message for any
serializations that fail to round-trip, and for any bin-io serializations that
exceed [max_binable_length]. *)valprint_and_check_stable_type:?cr:CR.t(** default is [CR] *)->?hide_positions:bool(** default is [false] when [cr=CR], [true] otherwise *)->?max_binable_length:int(** default is [Int.max_value] *)->Source_code_position.t->(moduleStable_without_comparatorwithtypet='a)->'alist->unit(** [print_and_check_stable_int63able_type] works like [print_and_check_stable_type],
and includes [Int63.t] serializations. *)valprint_and_check_stable_int63able_type:?cr:CR.t(** default is [CR] *)->?hide_positions:bool(** default is [false] when [cr=CR], [true] otherwise *)->?max_binable_length:int(** default is [Int.max_value] *)->Source_code_position.t->(moduleStable_int63ablewithtypet='a)->'alist->unit(** [print_and_check_container_sexps] prints the sexp representation of maps, sets, hash
tables, and hash sets based on the given values. For sets and hash sets, prints a
CR if the sexp does not correspond to a list of elements. For maps and hash tables,
prints a CR if the sexp does not correspond to an association list keyed on
elements. *)valprint_and_check_container_sexps:?cr:CR.t(** default is [CR] *)->?hide_positions:bool(** default is [false] when [cr=CR], [true] otherwise *)->Source_code_position.t->(moduleWith_containerswithtypet='a)->'alist->unit(** [print_and_check_comparable_sexps] is like [print_and_check_container_sexps] for
maps and sets only. *)valprint_and_check_comparable_sexps:?cr:CR.t(** default is [CR] *)->?hide_positions:bool(** default is [false] when [cr=CR], [true] otherwise *)->Source_code_position.t->(moduleWith_comparablewithtypet='a)->'alist->unit(** [print_and_check_hashable_sexps] is like [print_and_check_container_sexps] for hash
tables and hash sets only. *)valprint_and_check_hashable_sexps:?cr:CR.t(** default is [CR] *)->?hide_positions:bool(** default is [false] when [cr=CR], [true] otherwise *)->Source_code_position.t->(moduleWith_hashablewithtypet='a)->'alist->unit(** Removes strings that look like time spans; see [Time.Span]. *)valremove_time_spans:string->string(** {3 Allocation tests} *)moduleAllocation_limit:moduletypeofstructincludeAllocation_limitend(** [require_allocation_does_not_exceed] is a specialized form of [require] that only
produces output when [f ()] allocates more than the given limits. The output will
include the actual number of major and minor words allocated. We do NOT include
these numbers in the successful case because those numbers are not stable with
respect to compiler versions and build flags.
If [f] returns a value that should be ignored, use this idiom:
{[
ignore (require_allocation_does_not_exceed ... f : t)
]}
rather than this idiom:
{[
require_allocation_does_not_exceed ... (fun () -> ignore (f () : t))
]}
With the latter idiom, the compiler may optimize the computation of [f ()] taking
advantage of the fact that the result is ignored, and eliminate allocation that is
intended to be measured. With the former idiom, the compiler cannot do such
optimization and must compute the result of [f ()].
See documentation above about CRs and workflows for failing allocation tests. *)valrequire_allocation_does_not_exceed:?hide_positions:bool(** default is [false] *)->Allocation_limit.t->Source_code_position.t->(unit->'a)->'a(** [require_no_allocation here f] is equivalent to [require_allocation_does_not_exceed
(Minor_words 0) here f].
See documentation above about CRs and workflows for failing allocation tests. *)valrequire_no_allocation:?hide_positions:bool(** default is [false] *)->Source_code_position.t->(unit->'a)->'a(**/**)(** This module is called [Expect_test_helpers_core_private] rather than [Private]
because [include Expect_test_helpers_core] is a common idiom, and we don't want to
interfere with other [Private] modules or create problems due to multiple
definitions of [Private]. *)moduleExpect_test_helpers_core_private:sigvalrequire_allocation_does_not_exceed:?cr:CR.t->?hide_positions:bool->Allocation_limit.t->Source_code_position.t->(unit->'a)->'aendend