Home / Docs / Guides

Requirements and examples

Release v0.4.0

A requirement records a statement with its source and owner; derived from traces functions to it, and una trace <ID> lists them with their obligations. A generated requirement stays proposed until a person changes its source.

Examples are executable evidence next to the code: given installs handlers (never host capabilities), do runs one expression, and each expect checks result, fails V, performed @x.op or not performed @x.op. una test runs them with their effect traces. A do line whose call fails is checked with expect fails V, as parse_slug in §6 shows; do attempt f(x) with expect result == Err(V) checks the same through the Result.

una
module demo

requirement SEATS_1
  text "An event with no seats left is shown as sold out"
  source human
  owner box_office
  status active

pub kind Availability = SoldOut | Open

pub availability(remaining: Int) -> Availability
  ensures remaining < 1 implies result is SoldOut
  derived from SEATS_1
=
  if remaining < 1 then SoldOut else Open

example "no seats left is sold out"
  do availability(0)
  expect result is SoldOut