Documentation
¶
Index ¶
- type Action
- type Assertion
- type Assignment
- type BinaryOp
- type Block
- type Call
- type Contract
- type EnvRef
- type Expr
- type Field
- type FieldRef
- type ImportRegistry
- type ImportResolver
- type Invariant
- type LenExpr
- type LiteralBool
- type LiteralFloat
- type LiteralInt
- type LiteralNull
- type LiteralString
- type Model
- type ObjField
- type ObjectLiteral
- type Param
- type RegexLiteral
- type Scenario
- type Scope
- type Spec
- type Target
- type Token
- type TokenType
- type TypeExpr
- type UnaryOp
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action struct {
Name string `json:"name"`
Params []*Param `json:"params,omitempty"`
Steps []*Call `json:"steps,omitempty"`
}
Action is a named reusable sequence of plugin calls.
type Assertion ¶
type Assertion struct {
// Expression assertion field
Expr Expr `json:"expr,omitempty"` // boolean expression (invariants)
// Path assertion fields
Expected Expr `json:"expected,omitempty"` // expected value
Target string `json:"target,omitempty"` // field path or locator name
Plugin string `json:"plugin,omitempty"` // plugin namespace (from @ syntax)
Property string `json:"property,omitempty"` // assertion property name
}
Assertion is a check. Two forms:
- Path assertion (then blocks): Target + Expected are set. E.g. "from.balance: 70"
- Expression assertion (invariants): Expr is set. E.g. "output.from.balance >= 0"
type Assignment ¶
Assignment sets a concrete value: field: value
type Block ¶
type Block struct {
Assignments []*Assignment `json:"assignments,omitempty"` // concrete values (given blocks)
Predicates []Expr `json:"predicates,omitempty"` // when-predicate conditions (when blocks)
Assertions []*Assertion `json:"assertions,omitempty"` // then-block checks
}
Block is a braced section containing assignments, predicates, or assertions.
type Call ¶
type Call struct {
Namespace string `json:"namespace,omitempty"` // plugin name, empty for local actions
Method string `json:"method"`
Args []Expr `json:"args,omitempty"`
}
Call is an invocation: plugin.verb(args...) or action(args...)
type Contract ¶
type Contract struct {
Input []*Field `json:"input,omitempty"`
Output []*Field `json:"output,omitempty"`
}
Contract defines the input/output boundary of the system under test.
type Expr ¶
type Expr interface {
// contains filtered or unexported methods
}
Expr is an expression node.
type Field ¶
type Field struct {
Constraint Expr `json:"constraint,omitempty"` // optional constraint expression (nil when absent)
Name string `json:"name"`
Type TypeExpr `json:"type"`
}
Field is a typed field with an optional constraint.
type FieldRef ¶
type FieldRef struct {
Path string `json:"path"` // e.g., "input.from.balance", "output.error"
}
type ImportRegistry ¶ added in v1.2.0
type ImportRegistry map[string]ImportResolver
ImportRegistry maps adapter names (e.g., "openapi") to their resolvers.
type ImportResolver ¶ added in v1.2.0
ImportResolver converts an external schema file into speclang AST nodes.
type Invariant ¶
type Invariant struct {
When Expr `json:"when,omitempty"` // optional guard predicate (nil when absent)
Name string `json:"name"`
Assertions []*Assertion `json:"assertions,omitempty"` // body assertions
}
Invariant is a universal property that must hold across all valid inputs.
type LiteralBool ¶
type LiteralBool struct {
Value bool `json:"value"`
}
type LiteralFloat ¶ added in v1.2.0
type LiteralFloat struct {
Value float64 `json:"value"`
}
type LiteralInt ¶
type LiteralInt struct {
Value int `json:"value"`
}
type LiteralNull ¶
type LiteralNull struct{}
type LiteralString ¶
type LiteralString struct {
Value string `json:"value"`
}
type ObjectLiteral ¶
type ObjectLiteral struct {
Fields []*ObjField `json:"fields,omitempty"` // ordered key-value pairs
}
type RegexLiteral ¶
type RegexLiteral struct {
Pattern string `json:"pattern"`
}
type Scenario ¶
type Scenario struct {
Given *Block `json:"given,omitempty"` // concrete values
When *Block `json:"when,omitempty"` // predicate block (generative)
Then *Block `json:"then,omitempty"` // assertions
Name string `json:"name"`
}
Scenario is a test case -- concrete (given) or generative (when-predicate).
type Scope ¶
type Scope struct {
Name string `json:"name"`
Config map[string]Expr `json:"config,omitempty"` // opaque key-value pairs, interpreted by adapter
Contract *Contract `json:"contract,omitempty"`
Invariants []*Invariant `json:"invariants,omitempty"`
Scenarios []*Scenario `json:"scenarios,omitempty"`
}
Scope is a named grouping that owns a contract, invariants, and scenarios. The Config block is opaque key-value pairs interpreted by the adapter.
type Spec ¶
type Spec struct {
Uses []string `json:"uses,omitempty"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Target *Target `json:"target,omitempty"`
Locators map[string]string `json:"locators,omitempty"`
Models []*Model `json:"models,omitempty"`
Actions []*Action `json:"actions,omitempty"`
Scopes []*Scope `json:"scopes,omitempty"`
}
Spec is the top-level AST node for a parsed spec file.
func ParseFileWithImports ¶ added in v1.2.0
func ParseFileWithImports(path string, imports ImportRegistry) (*Spec, error)
ParseFileWithImports reads a spec file, resolves includes, and returns the AST. The imports registry maps adapter names to import resolvers for the import directive.
type Target ¶
type Target struct {
Fields map[string]Expr `json:"fields,omitempty"` // key -> value expression (may be EnvRef, LiteralString, etc.)
}
Target holds configuration for the system under test.
type TokenType ¶
type TokenType int
const ( // Literals TokenIdent TokenType = iota TokenInt TokenFloat TokenString TokenBool // Keywords TokenUse TokenSpec TokenModel TokenContract TokenInput TokenOutput TokenAction TokenInvariant TokenScenario TokenGiven TokenWhen TokenThen TokenTarget TokenLocators TokenPlugin TokenNull TokenScope TokenConfig TokenEnv TokenInclude TokenImport // Symbols TokenLBrace // { TokenRBrace // } TokenLParen // ( TokenRParen // ) TokenLBracket // [ TokenRBracket // ] TokenColon // : TokenComma // , TokenDot // . TokenAt // @ TokenQuestion // ? // Operators TokenEq // == TokenNeq // != TokenGt // > TokenLt // < TokenGte // >= TokenLte // <= TokenPlus // + TokenMinus // - TokenStar // * TokenAnd // && TokenOr // || TokenNot // ! TokenAssign // = // Special TokenComment TokenEOF )
type TypeExpr ¶
type TypeExpr struct {
Name string `json:"name"` // "int", "string", "bool", "float", "bytes", "array", "map", or model name
ElemType *TypeExpr `json:"elem_type,omitempty"` // element type for arrays
KeyType *TypeExpr `json:"key_type,omitempty"` // key type for maps
ValType *TypeExpr `json:"val_type,omitempty"` // value type for maps
Optional bool `json:"optional,omitempty"` // trailing ?
}
TypeExpr represents a type in the spec language.