OxL Reference

kw assert

Reserved keyword

The list of words: §1.4

Syntax

ebnf
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

oxl
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 check

— 4.6 Interfaces

oxl
mock Payments {
  charge(_)            => fail Timeout once, then Receipt{ id: 1 }
  refund(id) if id > 0 => Ok always
}
assert Payments.calls(.charge).count == 2

— 18.3 Mocks

Related diagnostics

fixture-yield, explicit-interface, interface-not-satisfied, mock-decl

See also