diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2020-08-25 09:43:54 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-24 19:43:54 -0400 |
commit | c4d5b01acfe0cac31f94743a57e8e619178ba563 (patch) | |
tree | 1987fe2e23c4db59a44159f4c7d21ecc61be4ad3 /std/testing | |
parent | 9b0f9c876529696c8008dda8b3606e34d3fe98dc (diff) |
feat: update to TypeScript 4.0 (#6514)
Diffstat (limited to 'std/testing')
-rw-r--r-- | std/testing/asserts_test.ts | 10 | ||||
-rw-r--r-- | std/testing/bench.ts | 6 | ||||
-rw-r--r-- | std/testing/bench_test.ts | 8 |
3 files changed, 17 insertions, 7 deletions
diff --git a/std/testing/asserts_test.ts b/std/testing/asserts_test.ts index 65645b06b..13dba756d 100644 --- a/std/testing/asserts_test.ts +++ b/std/testing/asserts_test.ts @@ -301,7 +301,9 @@ const createHeader = (): string[] => [ "", "", ` ${gray(bold("[Diff]"))} ${red(bold("Actual"))} / ${ - green(bold("Expected")) + green( + bold("Expected"), + ) }`, "", "", @@ -484,10 +486,7 @@ Deno.test({ Deno.test({ name: "strictly unequal fail case", fn(): void { - assertThrows( - () => assertNotStrictEquals(1, 1), - AssertionError, - ); + assertThrows(() => assertNotStrictEquals(1, 1), AssertionError); }, }); @@ -499,6 +498,7 @@ Deno.test({ assertArrayContains<boolean>([true, false], [true]); const value = { x: 1 }; assertStrictEquals<typeof value>(value, value); + // eslint-disable-next-line @typescript-eslint/ban-types assertNotStrictEquals<object>(value, { x: 1 }); }, }); diff --git a/std/testing/bench.ts b/std/testing/bench.ts index b8bf40a9b..e1d3c86c9 100644 --- a/std/testing/bench.ts +++ b/std/testing/bench.ts @@ -1,4 +1,5 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. +import { assert } from "../_util/assert.ts"; import { deepAssign } from "../_util/deep_assign.ts"; interface BenchmarkClock { @@ -70,11 +71,11 @@ export interface BenchmarkRunResult { /** Defines the current progress during the run of `runBenchmarks` */ export interface BenchmarkRunProgress extends BenchmarkRunResult { /** List of the queued benchmarks to run with their name and their run count */ - queued: Array<{ name: string; runsCount: number }>; + queued?: Array<{ name: string; runsCount: number }>; /** The currently running benchmark with its name, run count and the already finished measurements in milliseconds */ running?: { name: string; runsCount: number; measuredRunsMs: number[] }; /** Indicates in which state benchmarking currently is */ - state: ProgressState; + state?: ProgressState; } /** Defines the states `BenchmarkRunProgress` can be in */ @@ -232,6 +233,7 @@ export async function runBenchmarks( clock.for = name; // Remove benchmark from queued + assert(progress.queued); const queueIndex = progress.queued.findIndex( (queued) => queued.name === name && queued.runsCount === runs, ); diff --git a/std/testing/bench_test.ts b/std/testing/bench_test.ts index 97a923ac2..e4eada453 100644 --- a/std/testing/bench_test.ts +++ b/std/testing/bench_test.ts @@ -255,6 +255,7 @@ Deno.test({ let pc = 0; // Assert initial progress before running let progress = progressCallbacks[pc++]; + assert(progress.queued); assertEquals(progress.state, ProgressState.BenchmarkingStart); assertEquals(progress.filtered, 1); assertEquals(progress.queued.length, 2); @@ -265,6 +266,7 @@ Deno.test({ progress = progressCallbacks[pc++]; assertEquals(progress.state, ProgressState.BenchStart); assertEquals(progress.filtered, 1); + assert(progress.queued); assertEquals(progress.queued.length, 1); assert(!!progress.queued.find(({ name }) => name == "multiple")); assertEquals(progress.running, { @@ -277,6 +279,7 @@ Deno.test({ // Assert running result of bench "single" progress = progressCallbacks[pc++]; assertEquals(progress.state, ProgressState.BenchPartialResult); + assert(progress.queued); assertEquals(progress.queued.length, 1); assertEquals(progress.running!.measuredRunsMs.length, 1); assertEquals(progress.results.length, 0); @@ -284,6 +287,7 @@ Deno.test({ // Assert result of bench "single" progress = progressCallbacks[pc++]; assertEquals(progress.state, ProgressState.BenchResult); + assert(progress.queued); assertEquals(progress.queued.length, 1); assertEquals(progress.running, undefined); assertEquals(progress.results.length, 1); @@ -292,6 +296,7 @@ Deno.test({ // Assert start of bench "multiple" progress = progressCallbacks[pc++]; assertEquals(progress.state, ProgressState.BenchStart); + assert(progress.queued); assertEquals(progress.queued.length, 0); assertEquals(progress.running, { name: "multiple", @@ -303,6 +308,7 @@ Deno.test({ // Assert first result of bench "multiple" progress = progressCallbacks[pc++]; assertEquals(progress.state, ProgressState.BenchPartialResult); + assert(progress.queued); assertEquals(progress.queued.length, 0); assertEquals(progress.running!.measuredRunsMs.length, 1); assertEquals(progress.results.length, 1); @@ -310,6 +316,7 @@ Deno.test({ // Assert second result of bench "multiple" progress = progressCallbacks[pc++]; assertEquals(progress.state, ProgressState.BenchPartialResult); + assert(progress.queued); assertEquals(progress.queued.length, 0); assertEquals(progress.running!.measuredRunsMs.length, 2); assertEquals(progress.results.length, 1); @@ -317,6 +324,7 @@ Deno.test({ // Assert finish of bench "multiple" progress = progressCallbacks[pc++]; assertEquals(progress.state, ProgressState.BenchResult); + assert(progress.queued); assertEquals(progress.queued.length, 0); assertEquals(progress.running, undefined); assertEquals(progress.results.length, 2); |