flix

0.75.2

Assert

eff AssertSource

An effect used to perform assertions during program execution.

Operations

def assert(cond: Bool, msg: RichString): Unit \ Assert§ Source

Asserts that the given condition cond is true with a message msg.

Definitions

def assertEmpty(ma: m[a]): Unit \ Assert + Aef[m] with Foldable[m], ToString[m[a]]§ Source

Asserts that the given foldable ma is empty.

def assertEq(expected: { expected = a }, actual: a): Unit \ Assert with Eq[a], ToString[a]§ Source

Asserts that the given values expected and actual are equal.

def assertEqWithMsg(expected: { expected = a }, actual: a, msg: String): Unit \ Assert with Eq[a]§ Source

Asserts that the given values expected and actual are equal with the given message msg.

def assertErr(r: Result[e, a]): Unit \ Assert§ Source

Asserts that the given Result r is Err(e).

def assertFalse(cond: Bool): Unit \ Assert§ Source

Asserts that the given condition cond is false.

def assertFalseWithMsg(cond: Bool, msg: String): Unit \ Assert§ Source

Asserts that the given condition cond is false with the given message msg.

def assertMemberOf(x: a, ma: m[a]): Unit \ Assert + Aef[m] with Foldable[m], Eq[a], ToString[a], ToString[m[a]]§ Source

Asserts that the given element x is a member of the given foldable ma.

def assertNeq(unexpected: { unexpected = a }, actual: a): Unit \ Assert with Eq[a], ToString[a]§ Source

Asserts that the given values unexpected and actual are not equal.

def assertNeqWithMsg(unexpected: { unexpected = a }, actual: a, msg: String): Unit \ Assert with Eq[a]§ Source

Asserts that the given values unexpected and actual are not equal with the given message msg.

def assertNonEmpty(ma: m[a]): Unit \ Assert + Aef[m] with Foldable[m], ToString[m[a]]§ Source

Asserts that the given foldable ma is non-empty.

def assertNone(o: Option[a]): Unit \ Assert§ Source

Asserts that the given Option o is None.

def assertOk(r: Result[e, a]): Unit \ Assert§ Source

Asserts that the given Result r is Ok(v).

def assertSome(o: Option[a]): Unit \ Assert§ Source

Asserts that the given Option o is Some(v).

def assertTrue(cond: Bool): Unit \ Assert§ Source

Asserts that the given condition cond is true.

def assertTrueWithMsg(cond: Bool, msg: String): Unit \ Assert§ Source

Asserts that the given condition cond is true with the given message msg.

def fail(msg: String): Unit \ Assert§ Source

Unconditionally fails with the given message msg.

def handle(f: a -> b \ ef): a -> b \ (ef - Assert) + IO§ Source

Handles the Assert effect of the given function f by throwing exceptions on assertion failures.

In other words, re-interprets the Assert effect using the IO effect.

def handleWithLogger(f: a -> b \ ef): a -> b \ (ef - Assert) + Logger§ Source

Handles the Assert effect by logging assertion failures using the Logger effect.

Assertions continue execution after logging the assertion failure.

def handleWithNoOp(f: a -> b \ ef): a -> b \ ef - Assert§ Source

Handles the Assert effect by ignoring all assertions (no-op).

def handleWithPrompt(f: a -> b \ ef): a -> b \ (ef - Assert) + IO§ Source

Handles the Assert effect by prompting the user whether to continue execution.

When an assertion fails, prints the assertion failure and asks the user if they want to continue. If the user chooses not to continue, the program throws an exception.

def handleWithStdErr(f: a -> b \ ef): a -> b \ (ef - Assert) + IO§ Source

Handles the Assert effect by printing assertion failures to stderr.

Assertions continue execution after printing the assertion failure.

def handleWithStdOut(f: a -> b \ ef): a -> b \ (ef - Assert) + IO§ Source

Handles the Assert effect by printing assertion failures to stdout.

Assertions continue execution after printing the assertion failure.

@DefaultHandler
def runWithIO(f: Unit -> a \ ef): a \ (ef - Assert) + IO§ Source

Runs the Assert effect of the given function f by throwing exceptions on assertion failures.

In other words, re-interprets the Assert effect using the IO effect.

def runWithLogger(f: Unit -> a \ ef): a \ (ef - Assert) + Logger§ Source

Runs the Assert effect of the given function f by logging assertion failures using the Logger effect.

Assertions continue execution after logging the assertion failure.

def runWithNoOp(f: Unit -> a \ ef): a \ ef - Assert§ Source

Runs the Assert effect of the given function f by ignoring all assertions (no-op).

def runWithPrompt(f: Unit -> a \ ef): a \ (ef - Assert) + IO§ Source

Runs the Assert effect of the given function f by prompting the user whether to continue execution.

When an assertion fails, prints the assertion failure and asks the user if they want to continue. If the user chooses not to continue, the program throws an exception.

def runWithStdErr(f: Unit -> a \ ef): a \ (ef - Assert) + IO§ Source

Runs the Assert effect of the given function f by printing assertion failures to stderr.

Assertions continue execution after printing the assertion failure.

def runWithStdOut(f: Unit -> a \ ef): a \ (ef - Assert) + IO§ Source

Runs the Assert effect of the given function f by printing assertion failures to stdout.

Assertions continue execution after printing the assertion failure.

def success(msg: String): Unit \ Assert§ Source

Unconditionally succeeds with the given message msg.