$assert
$assert(cond)
assert(cond, "assertion failed: <source text>").
The $ calls the compiler expands at the call site.
$assert(cond)
assert(cond, "assertion failed: <source text>").
$assert_eq(a, b)
An error that names both source texts and both values when they differ.
$bnot(x)
bit32.bnot(x), for a parenthesized operand.
$dbg(expr)
Prints file:line: <source text> = <value> and returns the value.
@test function a_new_hero() local hp = 100 local bag = [ "sword", "shield", "rope" ] $expect(hp):toBe(100) $expect(bag):toHaveLength(3) $expect(function() error("locked") end):toThrow("locked") end
The test runner's expectation over a value. Each matcher is a method on it, typed from the value: toBe and toEqual take the value's own type, toHaveLength and toBeGreaterThan take a number. A matcher answers the expectation, so a chain reads left to right. The names are jest's, which is what lest writes.
The intrinsic runs under the runner alone. $expect outside a @test function or a @test namespace is an error, and so is $expect in a project that sets [test] lest = false: a failed matcher reports through the runner, and without one there is nothing to report to. A helper the test calls needs @test of its own, or a place inside a @test namespace, where a private member is a helper and not a test.
$map[["a", 1], ["b", 2]]
A HashMap of the pairs: HashMap.from({ ["a"] = 1, ["b"] = 2 }). Each pair is a two-item array; $map(["a", 1]) is the same.
$matches(e, Ok(_)) $matches(xs, [first, ...rest])
A pattern test without a match: true when the value fits the pattern. Any pattern a case takes; a name in it binds nothing here.
$nameof(a.b.c)
The string "c".
$set[1, 2, 3]
A Set of the values: Set.from({ 1, 2, 3 }). The parenthesis form, $set(1, 2, 3), is the same.
$stringify(expr)
The source text of expr as a string.
$todo("why")
error("todo at file:line: why").
$unreachable()error("unreachable at file:line").