Add a false assertion.

This commit is contained in:
Bauke 2022-12-27 21:03:27 +01:00
parent 85b835eba1
commit a0ee7b94c2
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
2 changed files with 15 additions and 0 deletions

View File

@ -28,6 +28,16 @@ export class TestContext {
);
}
/** Assert that the value is false. */
false(actual: boolean, title?: string): void {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-boolean-literal-compare
if (actual === false) {
return;
}
throw new AssertionError("Failed false assertion", actual, false, title);
}
/** Assert that the value is true. */
true(actual: boolean, title?: string): void {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-boolean-literal-compare

View File

@ -7,6 +7,11 @@ await setup("Assertions", async (group) => {
test.equals("A string!", "A string!", "string");
});
group.test("false", async (test) => {
test.false(1 < 0, "logic");
test.false(new Date() instanceof String, "instanceof");
});
group.test("true", async (test) => {
test.true(1 > 0, "logic");
test.true(new Date() instanceof Date, "instanceof");