package b0

  1. Overview
  2. Docs
Software construction and deployment kit

Install

dune-project
 Dependency

Authors

Maintainers

Sources

b0-0.0.6.tbz
sha512=e9aa779e66c08fc763019f16d4706f465d16c05d6400b58fbd0313317ef33ddea51952e2b058db28e65f7ddb7012f328c8bf02d8f1da17bb543348541a2587f0

doc/b0.std/B0_testing/Test/Patch/index.html

Module Test.PatchSource

Patching text and files.

This is used by snapshot testing, see Substitutions. Normally you don't need to use that.

Sourcetype subst = {
  1. first : int;
    (*

    First byte of range to replace.

    *)
  2. last : int;
    (*

    Last byte of range to replace.

    *)
  3. subst : string;
    (*

    The data substituted in the range.

    *)
}

The type for text substitutions.

Sourcetype t

The type for text file patches.

Sourceval make : src:string -> t

make ~src is an empty patch on source text src.

Sourceval is_empty : t -> bool

is_empty p is true iff p has no substitutions.

Sourceval src : t -> string

src p is the source text to patch.

Sourceval substs : t -> subst list

substs p are the substitutions to perform on p.

Sourceval add_subst : t -> subst -> t

add_subst p s adds substitution s to patch p.

Sourceval apply : t -> string

apply p is the text resulting from applying the substition of p to src p.

Patching files

Sourceval get : B0_std.Fpath.t -> t option

get file is the patch for file file. This is None only if file did not exist, in which case an error messages has been logged. The first time you lookup file you get an empty patch.

Sourceval update : B0_std.Fpath.t -> t -> unit

update file p updates the patch of file file to p.

Sourceval write_files : unit -> unit

write_files () writes the patched files. Note. if you are using Test.main, this is done automatically.

Run state

Sourceval src_root : unit -> B0_std.Fpath.t option

src_root () if present it prefixed to Test.loc path with Fpath.append for looking up files.