summaryrefslogtreecommitdiff
path: root/std/testing
diff options
context:
space:
mode:
Diffstat (limited to 'std/testing')
-rw-r--r--std/testing/README.md12
-rw-r--r--std/testing/asserts.ts87
-rw-r--r--std/testing/asserts_test.ts112
-rw-r--r--std/testing/bench.ts37
-rw-r--r--std/testing/bench_test.ts20
-rw-r--r--std/testing/diff.ts24
6 files changed, 148 insertions, 144 deletions
diff --git a/std/testing/README.md b/std/testing/README.md
index 0e0ee14e7..bc9d8af33 100644
--- a/std/testing/README.md
+++ b/std/testing/README.md
@@ -90,7 +90,7 @@ Deno.test("doesThrow", function (): void {
throw new TypeError("hello world!");
},
TypeError,
- "hello"
+ "hello",
);
});
@@ -109,7 +109,7 @@ Deno.test("doesThrow", async function (): Promise<void> {
await assertThrowsAsync(
async (): Promise<void> => {
throw new TypeError("hello world!");
- }
+ },
);
await assertThrowsAsync(async (): Promise<void> => {
throw new TypeError("hello world!");
@@ -119,12 +119,12 @@ Deno.test("doesThrow", async function (): Promise<void> {
throw new TypeError("hello world!");
},
TypeError,
- "hello"
+ "hello",
);
await assertThrowsAsync(
async (): Promise<void> => {
return Promise.reject(new Error());
- }
+ },
);
});
@@ -133,7 +133,7 @@ Deno.test("fails", async function (): Promise<void> {
await assertThrowsAsync(
async (): Promise<void> => {
console.log("Hello world");
- }
+ },
);
});
```
@@ -214,7 +214,7 @@ runBenchmarks({ silent: true }, (p: BenchmarkRunProgress) => {
// initial progress data
if (p.state === ProgressState.BenchmarkingStart) {
console.log(
- `Starting benchmarking. Queued: ${p.queued.length}, filtered: ${p.filtered}`
+ `Starting benchmarking. Queued: ${p.queued.length}, filtered: ${p.filtered}`,
);
}
// ...
diff --git a/std/testing/asserts.ts b/std/testing/asserts.ts
index 2a1358143..4b9241e55 100644
--- a/std/testing/asserts.ts
+++ b/std/testing/asserts.ts
@@ -22,12 +22,12 @@ export class AssertionError extends Error {
export function _format(v: unknown): string {
let string = globalThis.Deno
? Deno.inspect(v, {
- depth: Infinity,
- sorted: true,
- trailingComma: true,
- compact: false,
- iterableLimit: Infinity,
- })
+ depth: Infinity,
+ sorted: true,
+ trailingComma: true,
+ compact: false,
+ iterableLimit: Infinity,
+ })
: String(v);
if (typeof v == "string") {
string = `"${string.replace(/(?=["\\])/g, "\\")}"`;
@@ -62,9 +62,9 @@ function buildMessage(diffResult: ReadonlyArray<DiffResult<string>>): string[] {
messages.push("");
messages.push("");
messages.push(
- ` ${gray(bold("[Diff]"))} ${red(bold("Actual"))} / ${green(
- bold("Expected")
- )}`
+ ` ${gray(bold("[Diff]"))} ${red(bold("Actual"))} / ${
+ green(bold("Expected"))
+ }`,
);
messages.push("");
messages.push("");
@@ -163,13 +163,13 @@ export function assert(expr: unknown, msg = ""): asserts expr {
export function assertEquals(
actual: unknown,
expected: unknown,
- msg?: string
+ msg?: string,
): void;
export function assertEquals<T>(actual: T, expected: T, msg?: string): void;
export function assertEquals(
actual: unknown,
expected: unknown,
- msg?: string
+ msg?: string,
): void {
if (equal(actual, expected)) {
return;
@@ -180,7 +180,7 @@ export function assertEquals(
try {
const diffResult = diff(
actualString.split("\n"),
- expectedString.split("\n")
+ expectedString.split("\n"),
);
const diffMsg = buildMessage(diffResult).join("\n");
message = `Values are not equal:\n${diffMsg}`;
@@ -206,13 +206,13 @@ export function assertEquals(
export function assertNotEquals(
actual: unknown,
expected: unknown,
- msg?: string
+ msg?: string,
): void;
export function assertNotEquals<T>(actual: T, expected: T, msg?: string): void;
export function assertNotEquals(
actual: unknown,
expected: unknown,
- msg?: string
+ msg?: string,
): void {
if (!equal(actual, expected)) {
return;
@@ -245,7 +245,7 @@ export function assertNotEquals(
export function assertStrictEquals<T>(
actual: T,
expected: T,
- msg?: string
+ msg?: string,
): void {
if (actual === expected) {
return;
@@ -264,14 +264,15 @@ export function assertStrictEquals<T>(
.split("\n")
.map((l) => ` ${l}`)
.join("\n");
- message = `Values have the same structure but are not reference-equal:\n\n${red(
- withOffset
- )}\n`;
+ message =
+ `Values have the same structure but are not reference-equal:\n\n${
+ red(withOffset)
+ }\n`;
} else {
try {
const diffResult = diff(
actualString.split("\n"),
- expectedString.split("\n")
+ expectedString.split("\n"),
);
const diffMsg = buildMessage(diffResult).join("\n");
message = `Values are not strictly equal:\n${diffMsg}`;
@@ -291,7 +292,7 @@ export function assertStrictEquals<T>(
export function assertStringContains(
actual: string,
expected: string,
- msg?: string
+ msg?: string,
): void {
if (!actual.includes(expected)) {
if (!msg) {
@@ -314,17 +315,17 @@ export function assertStringContains(
export function assertArrayContains(
actual: ArrayLike<unknown>,
expected: ArrayLike<unknown>,
- msg?: string
+ msg?: string,
): void;
export function assertArrayContains<T>(
actual: ArrayLike<T>,
expected: ArrayLike<T>,
- msg?: string
+ msg?: string,
): void;
export function assertArrayContains(
actual: ArrayLike<unknown>,
expected: ArrayLike<unknown>,
- msg?: string
+ msg?: string,
): void {
const missing: unknown[] = [];
for (let i = 0; i < expected.length; i++) {
@@ -343,9 +344,9 @@ export function assertArrayContains(
return;
}
if (!msg) {
- msg = `actual: "${_format(actual)}" expected to contain: "${_format(
- expected
- )}"\nmissing: ${_format(missing)}`;
+ msg = `actual: "${_format(actual)}" expected to contain: "${
+ _format(expected)
+ }"\nmissing: ${_format(missing)}`;
}
throw new AssertionError(msg);
}
@@ -357,7 +358,7 @@ export function assertArrayContains(
export function assertMatch(
actual: string,
expected: RegExp,
- msg?: string
+ msg?: string,
): void {
if (!expected.test(actual)) {
if (!msg) {
@@ -384,7 +385,7 @@ export function assertThrows<T = void>(
fn: () => T,
ErrorClass?: Constructor,
msgIncludes = "",
- msg?: string
+ msg?: string,
): Error {
let doesThrow = false;
let error = null;
@@ -395,18 +396,20 @@ export function assertThrows<T = void>(
throw new AssertionError("A non-Error object was thrown.");
}
if (ErrorClass && !(e instanceof ErrorClass)) {
- msg = `Expected error to be instance of "${ErrorClass.name}", but was "${
- e.constructor.name
- }"${msg ? `: ${msg}` : "."}`;
+ msg =
+ `Expected error to be instance of "${ErrorClass.name}", but was "${e.constructor.name}"${
+ msg ? `: ${msg}` : "."
+ }`;
throw new AssertionError(msg);
}
if (
msgIncludes &&
!stripColor(e.message).includes(stripColor(msgIncludes))
) {
- msg = `Expected error message to include "${msgIncludes}", but got "${
- e.message
- }"${msg ? `: ${msg}` : "."}`;
+ msg =
+ `Expected error message to include "${msgIncludes}", but got "${e.message}"${
+ msg ? `: ${msg}` : "."
+ }`;
throw new AssertionError(msg);
}
doesThrow = true;
@@ -428,7 +431,7 @@ export async function assertThrowsAsync<T = void>(
fn: () => Promise<T>,
ErrorClass?: Constructor,
msgIncludes = "",
- msg?: string
+ msg?: string,
): Promise<Error> {
let doesThrow = false;
let error = null;
@@ -439,18 +442,20 @@ export async function assertThrowsAsync<T = void>(
throw new AssertionError("A non-Error object was thrown or rejected.");
}
if (ErrorClass && !(e instanceof ErrorClass)) {
- msg = `Expected error to be instance of "${ErrorClass.name}", but got "${
- e.name
- }"${msg ? `: ${msg}` : "."}`;
+ msg =
+ `Expected error to be instance of "${ErrorClass.name}", but got "${e.name}"${
+ msg ? `: ${msg}` : "."
+ }`;
throw new AssertionError(msg);
}
if (
msgIncludes &&
!stripColor(e.message).includes(stripColor(msgIncludes))
) {
- msg = `Expected error message to include "${msgIncludes}", but got "${
- e.message
- }"${msg ? `: ${msg}` : "."}`;
+ msg =
+ `Expected error message to include "${msgIncludes}", but got "${e.message}"${
+ msg ? `: ${msg}` : "."
+ }`;
throw new AssertionError(msg);
}
doesThrow = true;
diff --git a/std/testing/asserts_test.ts b/std/testing/asserts_test.ts
index c3059ebac..7ea73b5c0 100644
--- a/std/testing/asserts_test.ts
+++ b/std/testing/asserts_test.ts
@@ -29,14 +29,14 @@ Deno.test("testingEqual", function (): void {
assert(
equal(
{ hello: "world", hi: { there: "everyone" } },
- { hello: "world", hi: { there: "everyone" } }
- )
+ { hello: "world", hi: { there: "everyone" } },
+ ),
);
assert(
!equal(
{ hello: "world", hi: { there: "everyone" } },
- { hello: "world", hi: { there: "everyone else" } }
- )
+ { hello: "world", hi: { there: "everyone else" } },
+ ),
);
assert(equal(/deno/, /deno/));
assert(!equal(/deno/, /node/));
@@ -45,8 +45,8 @@ Deno.test("testingEqual", function (): void {
assert(
!equal(
new Date(2019, 0, 3, 4, 20, 1, 10),
- new Date(2019, 0, 3, 4, 20, 1, 20)
- )
+ new Date(2019, 0, 3, 4, 20, 1, 20),
+ ),
);
assert(equal(new Set([1]), new Set([1])));
assert(!equal(new Set([1]), new Set([2])));
@@ -65,20 +65,20 @@ Deno.test("testingEqual", function (): void {
new Map([
["foo", "bar"],
["baz", "baz"],
- ])
- )
+ ]),
+ ),
);
assert(
equal(
new Map([["foo", new Map([["bar", "baz"]])]]),
- new Map([["foo", new Map([["bar", "baz"]])]])
- )
+ new Map([["foo", new Map([["bar", "baz"]])]]),
+ ),
);
assert(
equal(
new Map([["foo", { bar: "baz" }]]),
- new Map([["foo", { bar: "baz" }]])
- )
+ new Map([["foo", { bar: "baz" }]]),
+ ),
);
assert(
equal(
@@ -89,8 +89,8 @@ Deno.test("testingEqual", function (): void {
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"]])));
@@ -100,14 +100,14 @@ Deno.test("testingEqual", function (): void {
new Map([
["foo", "bar"],
["bar", "baz"],
- ])
- )
+ ]),
+ ),
);
assert(
!equal(
new Map([["foo", new Map([["bar", "baz"]])]]),
- new Map([["foo", new Map([["bar", "qux"]])]])
- )
+ new Map([["foo", new Map([["bar", "qux"]])]]),
+ ),
);
assert(equal(new Map([[{ x: 1 }, true]]), new Map([[{ x: 1 }, true]])));
assert(!equal(new Map([[{ x: 1 }, true]]), new Map([[{ x: 1 }, false]])));
@@ -120,13 +120,13 @@ Deno.test("testingEqual", function (): void {
assert(equal(new Uint8Array([1, 2, 3, 4]), new Uint8Array([1, 2, 3, 4])));
assert(!equal(new Uint8Array([1, 2, 3, 4]), new Uint8Array([2, 1, 4, 3])));
assert(
- equal(new URL("https://example.test"), new URL("https://example.test"))
+ equal(new URL("https://example.test"), new URL("https://example.test")),
);
assert(
!equal(
new URL("https://example.test"),
- new URL("https://example.test/with-path")
- )
+ new URL("https://example.test/with-path"),
+ ),
);
});
@@ -137,7 +137,7 @@ Deno.test("testingNotEquals", function (): void {
assertNotEquals("Denosaurus", "Tyrannosaurus");
assertNotEquals(
new Date(2019, 0, 3, 4, 20, 1, 10),
- new Date(2019, 0, 3, 4, 20, 1, 20)
+ new Date(2019, 0, 3, 4, 20, 1, 20),
);
let didThrow;
try {
@@ -172,7 +172,7 @@ Deno.test("testingArrayContains", function (): void {
assertArrayContains(fixtureObject, [{ deno: "luv" }]);
assertArrayContains(
Uint8Array.from([1, 2, 3, 4]),
- Uint8Array.from([1, 2, 3])
+ Uint8Array.from([1, 2, 3]),
);
assertThrows(
(): void => assertArrayContains(fixtureObject, [{ deno: "node" }]),
@@ -193,7 +193,7 @@ missing: [
{
deno: "node",
},
-]`
+]`,
);
});
@@ -204,7 +204,7 @@ Deno.test("testingAssertStringContainsThrow", function (): void {
} catch (e) {
assert(
e.message ===
- `actual: "Denosaurus from Jurassic" expected to contain: "Raptor"`
+ `actual: "Denosaurus from Jurassic" expected to contain: "Raptor"`,
);
assert(e instanceof AssertionError);
didThrow = true;
@@ -223,7 +223,7 @@ Deno.test("testingAssertStringMatchingThrows", function (): void {
} catch (e) {
assert(
e.message ===
- `actual: "Denosaurus from Jurassic" expected to match: "/Raptor/"`
+ `actual: "Denosaurus from Jurassic" expected to match: "/Raptor/"`,
);
assert(e instanceof AssertionError);
didThrow = true;
@@ -262,7 +262,7 @@ Deno.test("testingAssertFail", function (): void {
fail("foo");
},
AssertionError,
- "Failed assertion: foo"
+ "Failed assertion: foo",
);
});
@@ -276,11 +276,11 @@ Deno.test("testingAssertFailWithWrongErrorClass", function (): void {
fail("foo");
},
TypeError,
- "Failed assertion: foo"
+ "Failed assertion: foo",
);
},
AssertionError,
- `Expected error to be instance of "TypeError", but was "AssertionError"`
+ `Expected error to be instance of "TypeError", but was "AssertionError"`,
);
});
@@ -299,9 +299,9 @@ Deno.test("testingAssertThrowsAsyncWithReturnType", () => {
const createHeader = (): string[] => [
"",
"",
- ` ${gray(bold("[Diff]"))} ${red(bold("Actual"))} / ${green(
- bold("Expected")
- )}`,
+ ` ${gray(bold("[Diff]"))} ${red(bold("Actual"))} / ${
+ green(bold("Expected"))
+ }`,
"",
"",
];
@@ -332,7 +332,7 @@ Deno.test({
removed(`- ${yellow("1")}`),
added(`+ ${yellow("2")}`),
"",
- ].join("\n")
+ ].join("\n"),
);
},
});
@@ -348,7 +348,7 @@ Deno.test({
...createHeader(),
removed(`- ${yellow("1")}`),
added(`+ "1"`),
- ].join("\n")
+ ].join("\n"),
);
},
});
@@ -365,7 +365,7 @@ Deno.test({
+ "1",
"2",
3,
- ]`
+ ]`,
);
},
});
@@ -385,7 +385,7 @@ Deno.test({
+ ],
- b: "2",
- c: 3,
- }`
+ }`,
);
},
});
@@ -397,7 +397,7 @@ Deno.test({
(): void =>
assertEquals(
new Date(2019, 0, 3, 4, 20, 1, 10),
- new Date(2019, 0, 3, 4, 20, 1, 20)
+ new Date(2019, 0, 3, 4, 20, 1, 20),
),
AssertionError,
[
@@ -406,7 +406,7 @@ Deno.test({
removed(`- ${new Date(2019, 0, 3, 4, 20, 1, 10).toISOString()}`),
added(`+ ${new Date(2019, 0, 3, 4, 20, 1, 20).toISOString()}`),
"",
- ].join("\n")
+ ].join("\n"),
);
},
});
@@ -441,7 +441,7 @@ Deno.test({
+ 3,
+ ],
- b: 2,
- }`
+ }`,
);
},
});
@@ -457,7 +457,7 @@ Deno.test({
{
a: 1,
b: 2,
- }`
+ }`,
);
},
});
@@ -481,11 +481,11 @@ Deno.test("Assert Throws Non-Error Fail", () => {
throw "Panic!";
},
String,
- "Panic!"
+ "Panic!",
);
},
AssertionError,
- "A non-Error object was thrown."
+ "A non-Error object was thrown.",
);
assertThrows(
@@ -495,7 +495,7 @@ Deno.test("Assert Throws Non-Error Fail", () => {
});
},
AssertionError,
- "A non-Error object was thrown."
+ "A non-Error object was thrown.",
);
assertThrows(
@@ -505,7 +505,7 @@ Deno.test("Assert Throws Non-Error Fail", () => {
});
},
AssertionError,
- "A non-Error object was thrown."
+ "A non-Error object was thrown.",
);
});
@@ -517,11 +517,11 @@ Deno.test("Assert Throws Async Non-Error Fail", () => {
return Promise.reject("Panic!");
},
String,
- "Panic!"
+ "Panic!",
);
},
AssertionError,
- "A non-Error object was thrown or rejected."
+ "A non-Error object was thrown or rejected.",
);
assertThrowsAsync(
@@ -531,7 +531,7 @@ Deno.test("Assert Throws Async Non-Error Fail", () => {
});
},
AssertionError,
- "A non-Error object was thrown or rejected."
+ "A non-Error object was thrown or rejected.",
);
assertThrowsAsync(
@@ -541,7 +541,7 @@ Deno.test("Assert Throws Async Non-Error Fail", () => {
});
},
AssertionError,
- "A non-Error object was thrown or rejected."
+ "A non-Error object was thrown or rejected.",
);
assertThrowsAsync(
@@ -551,7 +551,7 @@ Deno.test("Assert Throws Async Non-Error Fail", () => {
});
},
AssertionError,
- "A non-Error object was thrown or rejected."
+ "A non-Error object was thrown or rejected.",
);
});
@@ -568,7 +568,7 @@ Deno.test("assertEquals diff for differently ordered objects", () => {
ccccccccccccccccccccccc: 1,
aaaaaaaaaaaaaaaaaaaaaaaa: 0,
bbbbbbbbbbbbbbbbbbbbbbbb: 0,
- }
+ },
);
},
AssertionError,
@@ -578,7 +578,7 @@ Deno.test("assertEquals diff for differently ordered objects", () => {
bbbbbbbbbbbbbbbbbbbbbbbb: 0,
- ccccccccccccccccccccccc: 0,
+ ccccccccccccccccccccccc: 1,
- }`
+ }`,
);
});
@@ -592,7 +592,7 @@ Deno.test("assert diff formatting", () => {
`{
a: 1,
b: 2,
-}`
+}`,
);
// Same for nested small objects.
@@ -609,7 +609,7 @@ Deno.test("assert diff formatting", () => {
"b",
],
},
-]`
+]`,
);
// Grouping is disabled.
@@ -623,7 +623,7 @@ Deno.test("assert diff formatting", () => {
"i",
"i",
"i",
-]`
+]`,
);
});
@@ -633,7 +633,7 @@ Deno.test("Assert Throws Parent Error", () => {
throw new AssertionError("Fail!");
},
Error,
- "Fail!"
+ "Fail!",
);
});
@@ -643,6 +643,6 @@ Deno.test("Assert Throws Async Parent Error", () => {
throw new AssertionError("Fail!");
},
Error,
- "Fail!"
+ "Fail!",
);
});
diff --git a/std/testing/bench.ts b/std/testing/bench.ts
index e6f4582b9..b8bf40a9b 100644
--- a/std/testing/bench.ts
+++ b/std/testing/bench.ts
@@ -112,17 +112,17 @@ function assertTiming(clock: BenchmarkClock): void {
if (!clock.stop) {
throw new BenchmarkRunError(
`Running benchmarks FAILED during benchmark named [${clock.for}]. The benchmark timer's stop method must be called`,
- clock.for
+ clock.for,
);
} else if (!clock.start) {
throw new BenchmarkRunError(
`Running benchmarks FAILED during benchmark named [${clock.for}]. The benchmark timer's start method must be called`,
- clock.for
+ clock.for,
);
} else if (clock.start > clock.stop) {
throw new BenchmarkRunError(
`Running benchmarks FAILED during benchmark named [${clock.for}]. The benchmark timer's start method must be called before its stop method`,
- clock.for
+ clock.for,
);
}
}
@@ -136,7 +136,7 @@ function createBenchmarkTimer(clock: BenchmarkClock): BenchmarkTimer {
if (isNaN(clock.start)) {
throw new BenchmarkRunError(
`Running benchmarks FAILED during benchmark named [${clock.for}]. The benchmark timer's start method must be called before its stop method`,
- clock.for
+ clock.for,
);
}
clock.stop = performance.now();
@@ -148,7 +148,7 @@ const candidates: BenchmarkDefinition[] = [];
/** Registers a benchmark as a candidate for the runBenchmarks executor. */
export function bench(
- benchmark: BenchmarkDefinition | BenchmarkFunction
+ benchmark: BenchmarkDefinition | BenchmarkFunction,
): void {
if (!benchmark.name) {
throw new Error("The benchmark function must not be anonymous");
@@ -171,7 +171,7 @@ export function clearBenchmarks({
skip = /$^/,
}: BenchmarkClearOptions = {}): void {
const keep = candidates.filter(
- ({ name }): boolean => !only.test(name) || skip.test(name)
+ ({ name }): boolean => !only.test(name) || skip.test(name),
);
candidates.splice(0, candidates.length);
candidates.push(...keep);
@@ -185,11 +185,11 @@ export function clearBenchmarks({
*/
export async function runBenchmarks(
{ only = /[^\s]/, skip = /^\s*$/, silent }: BenchmarkRunOptions = {},
- progressCb?: (progress: BenchmarkRunProgress) => void | Promise<void>
+ progressCb?: (progress: BenchmarkRunProgress) => void | Promise<void>,
): Promise<BenchmarkRunResult> {
// Filtering candidates by the "only" and "skip" constraint
const benchmarks: BenchmarkDefinition[] = candidates.filter(
- ({ name }): boolean => only.test(name) && !skip.test(name)
+ ({ name }): boolean => only.test(name) && !skip.test(name),
);
// Init main counters and error flag
const filtered = candidates.length - benchmarks.length;
@@ -217,7 +217,7 @@ export async function runBenchmarks(
console.log(
"running",
benchmarks.length,
- `benchmark${benchmarks.length === 1 ? " ..." : "s ..."}`
+ `benchmark${benchmarks.length === 1 ? " ..." : "s ..."}`,
);
}
@@ -233,7 +233,7 @@ export async function runBenchmarks(
// Remove benchmark from queued
const queueIndex = progress.queued.findIndex(
- (queued) => queued.name === name && queued.runsCount === runs
+ (queued) => queued.name === name && queued.runsCount === runs,
);
if (queueIndex != -1) {
progress.queued.splice(queueIndex, 1);
@@ -268,17 +268,16 @@ export async function runBenchmarks(
await publishProgress(
progress,
ProgressState.BenchPartialResult,
- progressCb
+ progressCb,
);
// Resetting the benchmark clock
clock.start = clock.stop = NaN;
// Once all ran
if (!--pendingRuns) {
- result =
- runs == 1
- ? `${totalMs}ms`
- : `${runs} runs avg: ${totalMs / runs}ms`;
+ result = runs == 1
+ ? `${totalMs}ms`
+ : `${runs} runs avg: ${totalMs / runs}ms`;
// Adding results
progress.results.push({
name,
@@ -293,7 +292,7 @@ export async function runBenchmarks(
await publishProgress(
progress,
ProgressState.BenchResult,
- progressCb
+ progressCb,
);
break;
}
@@ -329,7 +328,7 @@ export async function runBenchmarks(
// Closing results
console.log(
`benchmark result: ${failError ? red("FAIL") : blue("DONE")}. ` +
- `${progress.results.length} measured; ${filtered} filtered`
+ `${progress.results.length} measured; ${filtered} filtered`,
);
}
@@ -349,14 +348,14 @@ export async function runBenchmarks(
async function publishProgress(
progress: BenchmarkRunProgress,
state: ProgressState,
- progressCb?: (progress: BenchmarkRunProgress) => void | Promise<void>
+ progressCb?: (progress: BenchmarkRunProgress) => void | Promise<void>,
): Promise<void> {
progressCb && (await progressCb(cloneProgressWithState(progress, state)));
}
function cloneProgressWithState(
progress: BenchmarkRunProgress,
- state: ProgressState
+ state: ProgressState,
): BenchmarkRunProgress {
return deepAssign({}, progress, { state }) as BenchmarkRunProgress;
}
diff --git a/std/testing/bench_test.ts b/std/testing/bench_test.ts
index b6d64ab89..97a923ac2 100644
--- a/std/testing/bench_test.ts
+++ b/std/testing/bench_test.ts
@@ -46,8 +46,8 @@ Deno.test({
async (denoland: string): Promise<void> => {
const r = await fetch(denoland);
await r.text();
- }
- )
+ },
+ ),
);
b.stop();
});
@@ -73,7 +73,7 @@ Deno.test({
assertEquals(benchResult.results.length, 5);
const resultWithSingleRunsFiltered = benchResult.results.filter(
- ({ name }) => name === "forDecrementX1e9"
+ ({ name }) => name === "forDecrementX1e9",
);
assertEquals(resultWithSingleRunsFiltered.length, 1);
@@ -85,7 +85,7 @@ Deno.test({
assertEquals(resultWithSingleRuns.measuredRunsMs.length, 1);
const resultWithMultipleRunsFiltered = benchResult.results.filter(
- ({ name }) => name === "runs100ForIncrementX1e6"
+ ({ name }) => name === "runs100ForIncrementX1e6",
);
assertEquals(resultWithMultipleRunsFiltered.length, 1);
@@ -108,7 +108,7 @@ Deno.test({
bench(() => {});
},
Error,
- "The benchmark function must not be anonymous"
+ "The benchmark function must not be anonymous",
);
},
});
@@ -125,7 +125,7 @@ Deno.test({
await runBenchmarks({ only: /benchWithoutStop/, silent: true });
},
BenchmarkRunError,
- "The benchmark timer's stop method must be called"
+ "The benchmark timer's stop method must be called",
);
},
});
@@ -142,7 +142,7 @@ Deno.test({
await runBenchmarks({ only: /benchWithoutStart/, silent: true });
},
BenchmarkRunError,
- "The benchmark timer's start method must be called"
+ "The benchmark timer's start method must be called",
);
},
});
@@ -160,7 +160,7 @@ Deno.test({
await runBenchmarks({ only: /benchStopBeforeStart/, silent: true });
},
BenchmarkRunError,
- "The benchmark timer's start method must be called before its stop method"
+ "The benchmark timer's start method must be called before its stop method",
);
},
});
@@ -249,7 +249,7 @@ Deno.test({
{ skip: /skip/, silent: true },
(progress) => {
progressCallbacks.push(progress);
- }
+ },
);
let pc = 0;
@@ -322,7 +322,7 @@ Deno.test({
assertEquals(progress.results.length, 2);
assert(!!progress.results.find(({ name }) => name == "single"));
const resultOfMultiple = progress.results.filter(
- ({ name }) => name == "multiple"
+ ({ name }) => name == "multiple",
);
assertEquals(resultOfMultiple.length, 1);
assert(!!resultOfMultiple[0].measuredRunsMs);
diff --git a/std/testing/diff.ts b/std/testing/diff.ts
index da1e827ac..3a9eca4bb 100644
--- a/std/testing/diff.ts
+++ b/std/testing/diff.ts
@@ -41,7 +41,7 @@ export default function diff<T>(A: T[], B: T[]): Array<DiffResult<T>> {
const suffixCommon = createCommon(
A.slice(prefixCommon.length),
B.slice(prefixCommon.length),
- true
+ true,
).reverse();
A = suffixCommon.length
? A.slice(prefixCommon.length, -suffixCommon.length)
@@ -57,16 +57,16 @@ export default function diff<T>(A: T[], B: T[]): Array<DiffResult<T>> {
if (!N) {
return [
...prefixCommon.map(
- (c): DiffResult<typeof c> => ({ type: DiffType.common, value: c })
+ (c): DiffResult<typeof c> => ({ type: DiffType.common, value: c }),
),
...A.map(
(a): DiffResult<typeof a> => ({
type: swapped ? DiffType.added : DiffType.removed,
value: a,
- })
+ }),
),
...suffixCommon.map(
- (c): DiffResult<typeof c> => ({ type: DiffType.common, value: c })
+ (c): DiffResult<typeof c> => ({ type: DiffType.common, value: c }),
),
];
}
@@ -91,7 +91,7 @@ export default function diff<T>(A: T[], B: T[]): Array<DiffResult<T>> {
A: T[],
B: T[],
current: FarthestPoint,
- swapped: boolean
+ swapped: boolean,
): Array<{
type: DiffType;
value: T;
@@ -133,7 +133,7 @@ export default function diff<T>(A: T[], B: T[]): Array<DiffResult<T>> {
slide: FarthestPoint,
down: FarthestPoint,
k: number,
- M: number
+ M: number,
): FarthestPoint {
if (slide && slide.y === -1 && down && down.y === -1) {
return { y: 0, id: 0 };
@@ -163,7 +163,7 @@ export default function diff<T>(A: T[], B: T[]): Array<DiffResult<T>> {
down: FarthestPoint,
_offset: number,
A: T[],
- B: T[]
+ B: T[],
): FarthestPoint {
const M = A.length;
const N = B.length;
@@ -189,7 +189,7 @@ export default function diff<T>(A: T[], B: T[]): Array<DiffResult<T>> {
fp[k + 1 + offset],
offset,
A,
- B
+ B,
);
}
for (let k = delta + p; k > delta; --k) {
@@ -199,7 +199,7 @@ export default function diff<T>(A: T[], B: T[]): Array<DiffResult<T>> {
fp[k + 1 + offset],
offset,
A,
- B
+ B,
);
}
fp[delta + offset] = snake(
@@ -208,16 +208,16 @@ export default function diff<T>(A: T[], B: T[]): Array<DiffResult<T>> {
fp[delta + 1 + offset],
offset,
A,
- B
+ B,
);
}
return [
...prefixCommon.map(
- (c): DiffResult<typeof c> => ({ type: DiffType.common, value: c })
+ (c): DiffResult<typeof c> => ({ type: DiffType.common, value: c }),
),
...backTrace(A, B, fp[delta + offset], swapped),
...suffixCommon.map(
- (c): DiffResult<typeof c> => ({ type: DiffType.common, value: c })
+ (c): DiffResult<typeof c> => ({ type: DiffType.common, value: c }),
),
];
}