Documentation
¶
Overview ¶
Package assert evaluates a case's expect sections against a target result.
The Evaluate entry point and the answer/sources/tools/limits/golden checks live in evaluate.go; the expect.json path matchers and the ParseAnswerJSON preprocessor live in json.go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseAnswerJSON ¶
ParseAnswerJSON extracts a JSON document from an answer that may be wrapped in a markdown code fence or surrounding prose. It returns the extracted JSON and whether it parses. The rules, applied in order:
- trim surrounding whitespace;
- if the text is a ```json … ``` (or bare ``` … ```) fence, strip it;
- if the result is valid JSON, use it;
- otherwise take the substring from the first '{' to the last '}' and try that;
- if nothing parses, return the processed text with ok=false.
It is exported so `bench record`/report can reuse the same preprocessor.
Types ¶
type Result ¶
type Result struct {
Name string `json:"name"` // e.g. `answer contains "45 minutes"` or `json overall_status`
Status Status `json:"status"` //
Message string `json:"message,omitempty"` // failure/skip detail with expected vs got
}
Result is the outcome of one assertion.
func Evaluate ¶
Evaluate runs every assertion in exp against res. golden may be nil (the golden assertion then fails with a hint to run `bench record`). Absent sections produce no Result rows. The judge section is NOT evaluated here — the runner calls the judge package and appends its Result.
func EvaluateError ¶
EvaluateError runs the expect.error section against a server-reported error (negative cases). limits.max_seconds is still checked when set, using the elapsed time until the error arrived.
func UnexpectedSuccess ¶
UnexpectedSuccess is the assertion recorded when expect.error is present but the server answered successfully.