Documentation
¶
Overview ¶
Package coverage is the statement-coverage extension of the runner: a collector the interpreter reports statement executions to, and the profile blocks a host renders from it.
Coverage is an interpreter feature. flatstack is a performance-oriented backend and carries no coverage support; a runner holding a collector executes interpreted (see runner.Runtime.SetCoverage).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
Block is one line-range entry of a coverage profile. Lines only: the parser records no columns, so a profile writer chooses them (the test command derives them from the source text).
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector accumulates statement execution counts, keyed by the statement nodes the parser produced.
A program is registered before it runs, seeding every executable statement at count zero under the filename it was loaded from. The entrypoint and every include register, so the files in a profile are the files get_included_files reports, and an included-but-unexecuted statement still appears, at zero.
func (*Collector) Blocks ¶
Blocks renders the collected counts as profile entries, sorted by file and position. Statements sharing a line range merge into one block: NumStmt adds up, and Count is the largest of theirs, which is how many times the line was reached — summing would charge `$a = 1; $b = 2;` twice per pass.
func (*Collector) Files ¶
Files returns every registered filename, sorted. A file appears whether or not it holds an executable statement: a file of pure declarations registers no counts, and a report that renders only counted blocks would omit it, reading as a gap where there is nothing to run.
func (*Collector) Functions ¶
Functions returns the registered declaration spans, sorted by file and position. Every function of every registered file appears, called or not: an uncalled function is the zero row a per-function report exists to show.
func (*Collector) Hit ¶
Hit charges one execution to a registered statement. An unregistered statement (a declaration, or a program built without the parser) is not counted.
func (*Collector) Register ¶
Register seeds every executable statement of program at count zero under filename. Declarations are not executable and are skipped; their bodies' statements carry spans of their own. A statement already registered keeps its count, so re-including a cached program does not reset it.