diff options
Diffstat (limited to 'std/testing')
-rw-r--r-- | std/testing/README.md | 16 | ||||
-rw-r--r-- | std/testing/asserts.ts | 12 | ||||
-rw-r--r-- | std/testing/asserts_test.ts | 28 | ||||
-rw-r--r-- | std/testing/diff.ts | 2 | ||||
-rw-r--r-- | std/testing/format.ts | 10 | ||||
-rw-r--r-- | std/testing/mod.ts | 38 | ||||
-rwxr-xr-x | std/testing/runner.ts | 4 | ||||
-rw-r--r-- | std/testing/test.ts | 20 |
8 files changed, 65 insertions, 65 deletions
diff --git a/std/testing/README.md b/std/testing/README.md index e2bd90b24..8d02f9d79 100644 --- a/std/testing/README.md +++ b/std/testing/README.md @@ -92,11 +92,9 @@ Using `assertThrows()`: ```ts test(function doesThrow(): void { - assertThrows( - (): void => { - throw new TypeError("hello world!"); - } - ); + assertThrows((): void => { + throw new TypeError("hello world!"); + }); assertThrows((): void => { throw new TypeError("hello world!"); }, TypeError); @@ -111,11 +109,9 @@ test(function doesThrow(): void { // This test will not pass test(function fails(): void { - assertThrows( - (): void => { - console.log("Hello world"); - } - ); + assertThrows((): void => { + console.log("Hello world"); + }); }); ``` diff --git a/std/testing/asserts.ts b/std/testing/asserts.ts index ceac52dbd..3ae45454c 100644 --- a/std/testing/asserts.ts +++ b/std/testing/asserts.ts @@ -56,12 +56,10 @@ function buildMessage(diffResult: ReadonlyArray<DiffResult<string>>): string[] { ); messages.push(""); messages.push(""); - diffResult.forEach( - (result: DiffResult<string>): void => { - const c = createColor(result.type); - messages.push(c(`${createSign(result.type)}${result.value}`)); - } - ); + diffResult.forEach((result: DiffResult<string>): void => { + const c = createColor(result.type); + messages.push(c(`${createSign(result.type)}${result.value}`)); + }); messages.push(""); return messages; @@ -131,7 +129,7 @@ export function equal(c: unknown, d: unknown): boolean { } /** Make an assertion, if not `true`, then throw. */ -export function assert(expr: boolean, msg = ""): void { +export function assert(expr: unknown, msg = ""): asserts expr { if (!expr) { throw new AssertionError(msg); } diff --git a/std/testing/asserts_test.ts b/std/testing/asserts_test.ts index 956d66e3e..be0502ce6 100644 --- a/std/testing/asserts_test.ts +++ b/std/testing/asserts_test.ts @@ -51,8 +51,14 @@ test(function testingEqual(): void { assert(equal(new Map(), new Map())); assert( equal( - new Map([["foo", "bar"], ["baz", "baz"]]), - new Map([["foo", "bar"], ["baz", "baz"]]) + new Map([ + ["foo", "bar"], + ["baz", "baz"] + ]), + new Map([ + ["foo", "bar"], + ["baz", "baz"] + ]) ) ); assert( @@ -69,14 +75,26 @@ test(function testingEqual(): void { ); assert( equal( - new Map([["foo", "bar"], ["baz", "qux"]]), - new Map([["baz", "qux"], ["foo", "bar"]]) + new Map([ + ["foo", "bar"], + ["baz", "qux"] + ]), + new Map([ + ["baz", "qux"], + ["foo", "bar"] + ]) ) ); assert(equal(new Map([["foo", ["bar"]]]), new Map([["foo", ["bar"]]]))); assert(!equal(new Map([["foo", "bar"]]), new Map([["bar", "baz"]]))); assert( - !equal(new Map([["foo", "bar"]]), new Map([["foo", "bar"], ["bar", "baz"]])) + !equal( + new Map([["foo", "bar"]]), + new Map([ + ["foo", "bar"], + ["bar", "baz"] + ]) + ) ); assert( !equal( diff --git a/std/testing/diff.ts b/std/testing/diff.ts index dd544ac24..38d632e9a 100644 --- a/std/testing/diff.ts +++ b/std/testing/diff.ts @@ -133,7 +133,7 @@ export default function diff<T>(A: T[], B: T[]): Array<DiffResult<T>> { k: number, M: number ): FarthestPoint { - if (slide && slide.y === -1 && (down && down.y === -1)) + if (slide && slide.y === -1 && down && down.y === -1) return { y: 0, id: 0 }; if ( (down && down.y === -1) || diff --git a/std/testing/format.ts b/std/testing/format.ts index 28937d567..953347c27 100644 --- a/std/testing/format.ts +++ b/std/testing/format.ts @@ -360,13 +360,11 @@ const getKeysOfEnumerableProperties = (object: {}): Array<string | symbol> => { const keys: Array<string | symbol> = Object.keys(object).sort(); if (Object.getOwnPropertySymbols) { - Object.getOwnPropertySymbols(object).forEach( - (symbol): void => { - if (Object.getOwnPropertyDescriptor(object, symbol)!.enumerable) { - keys.push(symbol); - } + Object.getOwnPropertySymbols(object).forEach((symbol): void => { + if (Object.getOwnPropertyDescriptor(object, symbol)!.enumerable) { + keys.push(symbol); } - ); + }); } return keys; diff --git a/std/testing/mod.ts b/std/testing/mod.ts index bd7642b81..3b6386d5b 100644 --- a/std/testing/mod.ts +++ b/std/testing/mod.ts @@ -203,14 +203,12 @@ function report(result: TestResult): void { } function printFailedSummary(results: TestResults): void { - results.cases.forEach( - (v): void => { - if (!v.ok) { - console.error(`${RED_BG_FAIL} ${red(v.name)}`); - console.error(v.error); - } + results.cases.forEach((v): void => { + if (!v.ok) { + console.error(`${RED_BG_FAIL} ${red(v.name)}`); + console.error(v.error); } - ); + }); } function printResults( @@ -321,14 +319,12 @@ async function runTestsSerial( print( GREEN_OK + " " + name + " " + promptTestTime(end - start, true) ); - results.cases.forEach( - (v): void => { - if (v.name === name) { - v.ok = true; - v.printed = true; - } + results.cases.forEach((v): void => { + if (v.name === name) { + v.ok = true; + v.printed = true; } - ); + }); } catch (err) { if (disableLog) { print(CLEAR_LINE, false); @@ -336,15 +332,13 @@ async function runTestsSerial( print(`${RED_FAILED} ${name}`); print(err.stack); stats.failed++; - results.cases.forEach( - (v): void => { - if (v.name === name) { - v.error = err; - v.ok = false; - v.printed = true; - } + results.cases.forEach((v): void => { + if (v.name === name) { + v.error = err; + v.ok = false; + v.printed = true; } - ); + }); if (exitOnFail) { break; } diff --git a/std/testing/runner.ts b/std/testing/runner.ts index 48bc4c9c3..d0e9546f5 100755 --- a/std/testing/runner.ts +++ b/std/testing/runner.ts @@ -204,8 +204,8 @@ async function main(): Promise<void> { const include = parsedArgs._.length > 0 - ? (parsedArgs._ as string[]).flatMap( - (fileGlob: string): string[] => fileGlob.split(",") + ? (parsedArgs._ as string[]).flatMap((fileGlob: string): string[] => + fileGlob.split(",") ) : ["."]; const exclude = diff --git a/std/testing/test.ts b/std/testing/test.ts index 93233f7cc..dd6d772f6 100644 --- a/std/testing/test.ts +++ b/std/testing/test.ts @@ -51,12 +51,10 @@ test(function testingAssertNotStrictEqual(): void { test(function testingDoesThrow(): void { let count = 0; - assertThrows( - (): void => { - count++; - throw new Error(); - } - ); + assertThrows((): void => { + count++; + throw new Error(); + }); assert(count === 1); }); @@ -64,12 +62,10 @@ test(function testingDoesNotThrow(): void { let count = 0; let didThrow = false; try { - assertThrows( - (): void => { - count++; - console.log("Hello world"); - } - ); + assertThrows((): void => { + count++; + console.log("Hello world"); + }); } catch (e) { assert(e.message === "Expected function to throw."); didThrow = true; |