kw assert
Reserved keyword
The list of words: §1.4
Syntax
Assert = "assert" Type ":" Bounds ;Grammar: App. A
Defined in
- 18.2 Assertions and fixtures — assert expr is executed in all profiles, including prod (profiles switch off only contracts, §6.7, and the output of dbg, §2.2); on failure
- 0.2 Notation — The grammar is written in EBNF (appendix A)
- 1.4 Keywords — Reserved (cannot be used as names)
- 4.6 Interfaces — Interfaces are structural
- 18.3 Mocks — mock S { … } replaces a service, interface or actor within a test.
- 18.4 Simulation — In sim the scheduler, network, clocks, randomness and disk failures are deterministic; the result depends only on the seed.
Examples
pub(api) interface Storage {
fn get(k: str) -> bytes? io
var fn put(k: str, v: bytes) io
fn has(k: str) -> bool io => get(k) != none // a default method
}
interface ReadWrite { embed Reader; embed Writer }
interface Container<T> { type Item = T; fn items() -> iter<T> }
@explicit interface Persistent { fn key() -> str }
assert FileStorage: Storage // static checkmock Payments {
charge(_) => fail Timeout once, then Receipt{ id: 1 }
refund(id) if id > 0 => Ok always
}
assert Payments.calls(.charge).count == 2Related diagnostics
fixture-yield, explicit-interface, interface-not-satisfied, mock-decl