crashtest.hxsmith.feature
The plug-in contract: one Feature per slice of the Haxe language.
A feature contributes any of:
declaretop-level types and helper members, once per programtypesvalue types the generator may pick for variables and parametersexprsways to build an expression of a requested typestmtsways to emit a statementshowhow to turn a value of one of its types into a deterministic String
A feature never calls another feature directly; it asks the Gen (g.expr(ty),
g.stmt(), g.fns, ...), so features can be added, removed or restricted with
--features/--exclude without touching one another. Register one with
@register; modules under features/ are imported automatically.
covers names what the feature exercises: constructors of expr_def in
haxe/src/core/ast.ml, or decl:<kind> / std:<name> tags for things the AST
does not list. crashtest hxsmith coverage checks this table against the
Haxe source so a language construct nobody generates is visible.
class Choice
One way to build something. build returns None to decline, having emitted nothing.
leaf usable when the expression budget is spent (must not recurse into g.expr
for a type that can recurse unboundedly)
nested a statement that opens blocks; unavailable at the statement-depth limit
Statement builders return True on success; expression builders return the source text.
weight: float
build: Callable[[], Union[str, bool, None]]
leaf: bool
leaf = False
nested: bool
nested = False
feature: str
feature = ''
init
def __init__(weight: float, build: Callable[[], Union[str, bool, None]], leaf: bool = False, nested: bool = False, feature: str = '') -> None
class Feature
name: str
name = ''
summary: str
summary = ''
covers: Sequence[str]
covers = ()
requires: Sequence[str]
requires = ()
order: int
order = 50
declare
def declare(g: 'Gen') -> None
types
def types(g: 'Gen', depth: int) -> Iterable[tuple]
(weight, Ty) pairs. depth is how deeply a composite type is nested.
exprs
def exprs(g: 'Gen', ty: 'Ty') -> Iterable[Choice]
stmts
def stmts(g: 'Gen') -> Iterable[Choice]
show
def show(g: 'Gen', ty: 'Ty', expr: str) -> Optional[str]
A String-typed expression printing expr, or None to defer to the next feature.
register
def register() -> type
resolve
def resolve(only: Optional[Iterable[str]] = None, exclude: Iterable[str] = ()) -> List[Feature]
The enabled features in declare order, with their requires pulled in.
REGISTRY: Dict[str, Feature]
REGISTRY = {}