Skip to content

astero.testing

Programs exercising every declared position.

astero.testing.generate

Programs that exercise every declared role.

The grammar says which positions bind, which declare, and which open a scope. That list is also a coverage obligation: each one is a case the derivations have to get right, and the standard library is not guaranteed to contain a good example of each.

So the generator is driven by the declaration rather than by a hand-written list of interesting programs. Ask the grammar for its binding positions, emit a program per position, and a role added to the declaration is fuzzed from the moment it is declared. missing_coverage is what turns that from a claim into a check.

Each snippet is ordinary Python source, so the oracles are CPython's own: ast.parse for contexts, symtable for scopes.

snippets

snippets() -> Mapping[str, str]

Every snippet, keyed by the production it exercises.

missing_coverage

missing_coverage(
    grammar: Grammar,
    scopes: Mapping[str, tuple[Scope, ...]],
    ns: str,
) -> set[str]

Declared positions with no snippet exercising them.

The point of the whole module: a role added to the declaration and not to the corpus shows up here rather than going untested.

scopes is a layer table, astero.python.SCOPES or one like it. Only its keys are read; the annotation said Mapping[str, Scope], which no caller has ever passed.

combinations

combinations(count: int, seed: int = 0) -> Iterator[str]

Snippets nested inside one another, to reach the interactions.

A binding position inside a comprehension inside a class body is where the hand-written binders in the corpus go wrong, and no single snippet gets there. The generator is seeded, so a failure is reproducible.