Testing

Testing — a small unit-testing vocabulary for Aeon. In Aeon a *test* is just a `Bool`-returning function marked with `@property`: the `--test` runner evaluates it and a `True` result is a pass. A function with arguments is a *property* (inputs are generated automatically from the argument types); a function with no arguments is a *unit test* (one concrete case). This library provides readable assertion combinators — every one returns `Bool` — so unit tests and property-based tests share the same vocabulary and the same runner. open Testing open Image # Unit test: one concrete case. `@property(1)` evaluates it exactly once. @property(1) def test_mk_dimensions : Bool = img = Image.mk 4 3 (Color.mk 255 0 0); assertEqual (Image.width img) 4; # Property: dimensions are generated; the assertion must hold for all of them. @property def prop_mk_width (w : {v:Int | v > 0 && v < 64}) : Bool = assertEqual (Image.width (Image.mk w 8 (Color.mk 0 0 0))) w; Run with: aeon --test yourfile.ae Notes ----- * Assertions are plain `Bool` values, so you compose them with the built-in `&&` / `||` / `!`, or with the `allOf*` helpers below to group several checks into one test. * Because an assertion is just a `Bool`, the same helpers work inside the `@example(...)` decorator (machine-checked documentation) as well. ── Boolean assertions ─────────────────────────────────────────────────── Passes when the condition holds. Use it to wrap any boolean expression that this library has no dedicated assertion for (e.g. `assertThat (mem x s)`).
Imports
open Math;
Table of Contents

Functions

assertThat

Passes when the condition holds. Use it to wrap any boolean expression that this library has no dedicated assertion for (e.g. `assertThat (mem x s)`).
def assertThat (condition: Bool) : Bool

assertTrue

Passes when the condition holds (alias of `assertThat`, reads well on a raw
def assertTrue (condition: Bool) : Bool

assertFalse

Passes when the condition is false.
def assertFalse (condition: Bool) : Bool

assertEqual

Passes when `actual` equals `expected`.
def assertEqual (actual: a) (expected: a) : Bool

assertNotEqual

Passes when `actual` differs from `expected`.
def assertNotEqual (actual: a) (expected: a) : Bool

assertLess

Passes when `actual < bound`.
def assertLess (actual: a) (bound: a) : Bool

assertLessEqual

Passes when `actual <= bound`.
def assertLessEqual (actual: a) (bound: a) : Bool

assertGreater

Passes when `actual > bound`.
def assertGreater (actual: a) (bound: a) : Bool

assertGreaterEqual

Passes when `actual >= bound`.
def assertGreaterEqual (actual: a) (bound: a) : Bool

assertClose

Passes when `actual` and `expected` are within `eps` of each other. Use this instead of `assertEqual` for any value produced by floating-point arithmetic.
def assertClose (actual: Float) (expected: Float) (eps: {v : Float | v ≥ 0.0}) : Bool

both

Passes when both checks pass.
def both (a: Bool) (b: Bool) : Bool

allOf3

Passes when all three checks pass.
def allOf3 (a: Bool) (b: Bool) (c: Bool) : Bool

allOf4

Passes when all four checks pass.
def allOf4 (a: Bool) (b: Bool) (c: Bool) (d: Bool) : Bool

allOf5

Passes when all five checks pass.
def allOf5 (a: Bool) (b: Bool) (c: Bool) (d: Bool) (e: Bool) : Bool