---
title: "14.9 Recap and reference"
url: https://una-lang.org/en/learn/testing/recap-and-reference/
release: v0.4.0
edition: "0.2"
---

# 14.9 Recap and reference

## 14.9.1 For agents

:::agents
`una --json check .` reports example mistakes in the same shape as any other. For [a misspelled operation](https://una-lang.org/en/learn/testing/common-mistakes/#a-misspelled-operation-u1001), with its exact edit:

```json include="mistakes/3/expected/commands/json.txt#L2"
{"schema":"una.diagnostics/1","diagnostics":[{"schema":"una.diagnostic/1","code":"U1001","severity":"error","domain":"names","message":"capability `Mailer` has no operation `sent`","primary":{"file":"src/checkout.una","start":{"line":139,"col":28},"end":{"line":139,"col":32}},"related":[],"repairs":[{"rank":1,"escape_cost":0,"description":"write `send`","edit":{"file":"src/checkout.una","start":{"line":139,"col":28},"end":{"line":139,"col":32},"replacement":"send"}}],"explain":"una explain U1001"}],"fixable":1}
```

`una --json test .` prints `una.test/1`. Each example has `outcome`, `reason`, the `expectation` that failed with its file and line, the `result`, and the `trace`. Each event of a trace has `seq`, `instance`, `capability`, `op`, `args` and `outcome`, so an agent can check arguments that `expect performed` does not. For [the dropped zero](https://una-lang.org/en/learn/testing/what-the-verifier-proves-and-what-examples-show/#a-bug-only-an-example-catches-a-dropped-zero) of section 14.4:

```json include="steps/25-dropped-zero/expected/commands/json-test.txt#L2"
{"schema":"una.test/1","tier":1,"redacted":false,"diagnostics":[],"examples":[{"module":"shipping","name":"an order of 49.99 pays 4.90","outcome":"fail","reason":"it is false, with `result` = `49`","expectation":{"file":"src/shipping.una","line":24,"text":"expect result == 490"},"result":{"kind":"ok","value":"49"},"trace":[]},{"module":"shipping","name":"an order of exactly 50.00 ships for free","outcome":"pass","reason":null,"expectation":null,"result":{"kind":"ok","value":"0"},"trace":[]}],"passed":1,"failed":1}
```

The compact rule: *an example has `given` lines for every capability its `do` line needs, one `do` line, and one or more `expect` lines; it never uses a host capability.*
:::

## 14.9.2 Recap

:::recap
- Write an `example` next to the code: a name a reader understands, one `do` line, and `expect` lines that must hold.
- `una test .` checks the package, runs every example in a fresh machine, and exits with code 1 when one fails.
- Give every failure path its own example with `expect fails`, naming a variant of the `do` call's error kind.
- Replace each service with a fake handler installed by `given`. Examples never use host capabilities.
- Check effects with `expect performed` and `expect not performed`: what a call must do, and what it must not.
- A fake is checked against the operations it implements, so it keeps their promises.
- Prove in `ensures` what must hold for every input; pin exact values, the edges of each rule, and effects with examples.
:::

## 14.9.3 Reference

:::reference
- Construct pages: [`example`](https://una-lang.org/en/docs/language/examples/example/), [`handler`](https://una-lang.org/en/docs/language/capabilities/handler/), [`with`](https://una-lang.org/en/docs/language/capabilities/with/), [`capability` and `op`](https://una-lang.org/en/docs/language/capabilities/capability/), [`ensures`](https://una-lang.org/en/docs/language/functions/ensures/), [`attempt`](https://una-lang.org/en/docs/language/errors/attempt/)
- Diagnostics: [U0101](https://una-lang.org/en/docs/errors/U0101/), [U1001](https://una-lang.org/en/docs/errors/U1001/), [U1002](https://una-lang.org/en/docs/errors/U1002/), [U2001](https://una-lang.org/en/docs/errors/U2001/), [U3001](https://una-lang.org/en/docs/errors/U3001/), [U3014](https://una-lang.org/en/docs/errors/U3014/), [U5001](https://una-lang.org/en/docs/errors/U5001/)
- Specification: [requirements and examples](https://una-lang.org/en/docs/spec/08-requirements-and-examples/), [capabilities and effects](https://una-lang.org/en/docs/spec/05-capabilities-and-effects/), [verification](https://una-lang.org/en/docs/spec/12-verification/), [dynamic semantics](https://una-lang.org/en/docs/spec/11-dynamic-semantics/) (traces and the example harness), [diagnostics and the command line](https://una-lang.org/en/docs/spec/13-diagnostics-and-abi/)
:::
