Add a false assertion.
This commit is contained in:
parent
85b835eba1
commit
a0ee7b94c2
|
@ -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. */
|
/** Assert that the value is true. */
|
||||||
true(actual: boolean, title?: string): void {
|
true(actual: boolean, title?: string): void {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-boolean-literal-compare
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-boolean-literal-compare
|
||||||
|
|
|
@ -7,6 +7,11 @@ await setup("Assertions", async (group) => {
|
||||||
test.equals("A string!", "A string!", "string");
|
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) => {
|
group.test("true", async (test) => {
|
||||||
test.true(1 > 0, "logic");
|
test.true(1 > 0, "logic");
|
||||||
test.true(new Date() instanceof Date, "instanceof");
|
test.true(new Date() instanceof Date, "instanceof");
|
||||||
|
|
Loading…
Reference in New Issue