assert
The “assert” module provides tools for testing various conditions and aborting the current fiber if the conditions do not hold.
Assert
static [p]
If !p, abort the current fiber with an error.
import "assert" for Assert
Assert[true] // No problem
Assert[false] // Aborts
static ok(p)
If !p, abort the current fiber with an error.
static ok(p, msg)
If !p, abort the current fiber with the given error message.
static not(p)
If p, abort the current fiber with an error.
static not(p, msg)
If p, abort the current fiber with the given error message.
static [a, b]
If a != b, abort the current fiber with an error.
import "assert" for Assert
Assert[2, 2] // ok, 2 == 2
Assert[2, 4] // not ok, 2 != 4
static [a, b, msg]
If a != b, abort the current fiber the given error message.
static equal(a, b)
If a != b, abort the current fiber with an error.
static equal(a, b, msg)
If a != b, abort the current fiber with the given error message.
static notEqual(a, b)
If a == b, abort the current fiber with an error.
static notEqual(a, b, msg)
If a == b, abort the current fiber with the given error message.
static aborts(fn)
Executes the given function, asserting that it aborts with an error.
import "assert" for Assert
// passes:
Assert.aborts {
Fiber.abort("hello world")
}
// fails:
Assert.aborts {
System.print("nothing to see here")
}
static aborts(fn, msg)
Executes the given function, asserting that it aborts with an error, aborting the fiber with a given error message if not.
static doesNotAbort(fn)
Executes the given function, asserting that it completes without error.
static doesNotAbort(fn, msg)
Executes the given function, asserting that it completes without error, printing an error message otherwise.