Module Shared_ast.Coverage

More efficient File map module

module ScopeSet : sig ... end

More efficient ScopeName set module

type cover =
  1. | Unreached
  2. | Reached_by of {
    1. scopes : ScopeSet.t;
    }

A position can either be Unreached or Reached_by a set of test scopes.

val format_cover : Stdlib.Format.formatter -> cover -> unit
type itv = private {
  1. start_line : int;
  2. start_col : int;
  3. end_line : int;
  4. end_col : int;
}
val from_pos : Catala_utils.Pos.t -> itv
val format_itv : Stdlib.Format.formatter -> itv -> unit
type coverage_map
val empty : coverage_map
val reached_pos : Catala_utils.Pos.t -> Shared_ast__.Definitions.ScopeName.t -> coverage_map -> coverage_map

reached_pos p s m marks the position p as reached by the scope s in the map m. Merge scopes if the position was already reached by another scope.

val unreached_pos : Catala_utils.Pos.t -> coverage_map -> coverage_map

unreached_pos p m marks the position p as unreached in the map m. Does not overwrite the existing cover.

val reachable_positions : ((_, _, _) Shared_ast__.Definitions.base_gexpr, _ Shared_ast__.Definitions.mark) Catala_utils.Mark.ed Shared_ast__.Definitions.program -> coverage_map

reachable_positions prg iterates over the program p's expressions to build a Unreached only coverage_map.

val merge_with_reachable_positions : reachable:coverage_map -> reached:coverage_map -> coverage_map

merge_with_reachable_positions ~reachable ~reached computes the union between reachable and reached but filter out files that do not contain reached positions. When a conflict occurs, the cover are merged, i.e., scopes are merged together.

val filter_files : (Catala_utils.File.t -> bool) -> coverage_map -> coverage_map

filter_files p m removes the files from the coverage map that do not satisfy the predicate p. Used to filter out the stdlib.

val fold : ((Catala_utils.File.t * itv) -> cover -> 'a -> 'a) -> coverage_map -> 'a -> 'a
val format_coverage_hex_dump : Stdlib.Format.formatter -> coverage_map -> unit

Marshal the coverage map and prints it as hexadecimal.

val of_hex : string -> coverage_map

Unmarshal the coverage map from an hexadecimal string.

type interval_tree = interval_node list

n-ary tree that modelize the coverage of a file. Every node's sub-trees are comprised in their parent wrt. their interval. This is the structure that should be exported.

and interval_node = {
  1. itv : itv;
  2. cover : cover;
  3. children : interval_tree;
}
val compute_interval_trees : coverage_map -> interval_tree FileMap.t

Build and normalize a coverage map into an interval tree.

val all_scopes : interval_tree -> ScopeSet.t

all_scopes itvt iterates over the interval tree itvt and returns the union of all scopes that produced a Reached_by cover.

val format_interval_tree : Stdlib.Format.formatter -> interval_tree -> unit