Skip to main content

Module assertion_coverage

Module assertion_coverage 

Source
Expand description

Assertions coverage: which executed statements a test would catch breaking.

A statement counts as asserted when changing it makes at least one passing test that executes it fail. The change follows the statement: an if has its condition inverted (each direction), return x returns undefined, a declaration’s value becomes undefined, an expression point evaluates to undefined, and any other statement is skipped. Imports, declarations without a value, and function, class and type declarations are not assessed.

Supercov does not decide this itself. For each test it renders what the test ran (its code, its helpers, and the source it executed) and asks Jev, one yes/no question per statement, whether the test would fail. This module owns the population, the change rules and the rendering; the CLI owns the requests, the answer cache and the output. What Jev sees for one statement and one test is also the cache key, so an answer is reused only when the question would be asked with exactly the same text.

Structs§

Population
Statement
TestRef

Enums§

Change
Language
The languages whose statements and tests this module can read.

Constants§

FIRST_TESTS
Tests asked about a statement before it may be called unchecked, then the wider set asked before it is (measured: more tests remove false “unchecked” flags, and 25 tests was no better than 15).
INSTRUCTIONS
MAX_QUESTIONS
MODEL
MORE_TESTS
THRESHOLD
A statement is asserted when some test’s answer is at least this.

Functions§

load_snapshot
Read files written by save_snapshot.
population
The executed statements of a run and the tests that ran them. sources are the run’s source files, verified against the run.
save_snapshot
Write files’ text, compressed, to path.