Documentation
¶
Overview ¶
Package assert provides the `assert(cond, msg)` keyword and the `@assert: expr` directive. The keyword yields a core.AssertExpr (evaluated later by the runtime with expr-lang); the directive appends its expression to meta["asserts"]. Core does not know what an assertion is: the parser dispatches the keyword through the bundle's Primaries, and the directive is handled by the bundle's Directive table.
Typical use:
@assert: result.status == "ok"
{ score: 95 } -> assert(.score >= 50, "score too low")
Index ¶
Constants ¶
View Source
const ID = "assert"
Variables ¶
View Source
var Directive = core.Directive{
Name: "assert",
Example: `@assert: result != nil`,
Handler: handleDirective,
}
Directive parses `@assert: EXPR` and appends EXPR to meta["asserts"]. The colon after "assert" is optional: `@assert: x == 1` and `@assert x == 1` are equivalent.
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.