assert

package
v0.20.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

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

func Bundle

func Bundle(_ map[string]string) core.Bundle

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL