summaryrefslogtreecommitdiff
path: root/std/testing
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2020-06-12 20:23:38 +0100
committerGitHub <noreply@github.com>2020-06-12 15:23:38 -0400
commit1fff6f55c3ba98a10018c6d374795e612061e9b6 (patch)
tree12074b6d44736b11513d857e437f9e30a6bf65a4 /std/testing
parent26bf56afdaf16634ffbaa23684faf3a44cc10f62 (diff)
refactor: Don't destructure the Deno namespace (#6268)
Diffstat (limited to 'std/testing')
-rw-r--r--std/testing/asserts_test.ts44
-rw-r--r--std/testing/bench.ts6
-rw-r--r--std/testing/bench_test.ts23
-rw-r--r--std/testing/diff_test.ts21
4 files changed, 44 insertions, 50 deletions
diff --git a/std/testing/asserts_test.ts b/std/testing/asserts_test.ts
index feb4d097d..7f2d978ea 100644
--- a/std/testing/asserts_test.ts
+++ b/std/testing/asserts_test.ts
@@ -1,5 +1,4 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
import {
assert,
assertNotEquals,
@@ -17,9 +16,8 @@ import {
unreachable,
} from "./asserts.ts";
import { red, green, gray, bold, yellow } from "../fmt/colors.ts";
-const { test } = Deno;
-test("testingEqual", function (): void {
+Deno.test("testingEqual", function (): void {
assert(equal("world", "world"));
assert(!equal("hello", "world"));
assert(equal(5, 5));
@@ -116,7 +114,7 @@ test("testingEqual", function (): void {
assert(!equal(new Uint8Array([1, 2, 3, 4]), new Uint8Array([2, 1, 4, 3])));
});
-test("testingNotEquals", function (): void {
+Deno.test("testingNotEquals", function (): void {
const a = { foo: "bar" };
const b = { bar: "foo" };
assertNotEquals(a, b);
@@ -132,7 +130,7 @@ test("testingNotEquals", function (): void {
assertEquals(didThrow, true);
});
-test("testingAssertStringContains", function (): void {
+Deno.test("testingAssertStringContains", function (): void {
assertStringContains("Denosaurus", "saur");
assertStringContains("Denosaurus", "Deno");
assertStringContains("Denosaurus", "rus");
@@ -147,7 +145,7 @@ test("testingAssertStringContains", function (): void {
assertEquals(didThrow, true);
});
-test("testingArrayContains", function (): void {
+Deno.test("testingArrayContains", function (): void {
const fixture = ["deno", "iz", "luv"];
const fixtureObject = [{ deno: "luv" }, { deno: "Js" }];
assertArrayContains(fixture, ["deno"]);
@@ -159,7 +157,7 @@ test("testingArrayContains", function (): void {
);
});
-test("testingAssertStringContainsThrow", function (): void {
+Deno.test("testingAssertStringContainsThrow", function (): void {
let didThrow = false;
try {
assertStringContains("Denosaurus from Jurassic", "Raptor");
@@ -174,11 +172,11 @@ test("testingAssertStringContainsThrow", function (): void {
assert(didThrow);
});
-test("testingAssertStringMatching", function (): void {
+Deno.test("testingAssertStringMatching", function (): void {
assertMatch("foobar@deno.com", RegExp(/[a-zA-Z]+@[a-zA-Z]+.com/));
});
-test("testingAssertStringMatchingThrows", function (): void {
+Deno.test("testingAssertStringMatchingThrows", function (): void {
let didThrow = false;
try {
assertMatch("Denosaurus from Jurassic", RegExp(/Raptor/));
@@ -193,7 +191,7 @@ test("testingAssertStringMatchingThrows", function (): void {
assert(didThrow);
});
-test("testingAssertsUnimplemented", function (): void {
+Deno.test("testingAssertsUnimplemented", function (): void {
let didThrow = false;
try {
unimplemented();
@@ -205,7 +203,7 @@ test("testingAssertsUnimplemented", function (): void {
assert(didThrow);
});
-test("testingAssertsUnreachable", function (): void {
+Deno.test("testingAssertsUnreachable", function (): void {
let didThrow = false;
try {
unreachable();
@@ -217,7 +215,7 @@ test("testingAssertsUnreachable", function (): void {
assert(didThrow);
});
-test("testingAssertFail", function (): void {
+Deno.test("testingAssertFail", function (): void {
assertThrows(fail, AssertionError, "Failed assertion.");
assertThrows(
(): void => {
@@ -228,7 +226,7 @@ test("testingAssertFail", function (): void {
);
});
-test("testingAssertFailWithWrongErrorClass", function (): void {
+Deno.test("testingAssertFailWithWrongErrorClass", function (): void {
assertThrows(
(): void => {
//This next assertThrows will throw an AssertionError due to the wrong
@@ -246,14 +244,14 @@ test("testingAssertFailWithWrongErrorClass", function (): void {
);
});
-test("testingAssertThrowsWithReturnType", () => {
+Deno.test("testingAssertThrowsWithReturnType", () => {
assertThrows(() => {
throw new Error();
return "a string";
});
});
-test("testingAssertThrowsAsyncWithReturnType", () => {
+Deno.test("testingAssertThrowsAsyncWithReturnType", () => {
assertThrowsAsync(() => {
throw new Error();
return Promise.resolve("a Promise<string>");
@@ -273,7 +271,7 @@ const createHeader = (): string[] => [
const added: (s: string) => string = (s: string): string => green(bold(s));
const removed: (s: string) => string = (s: string): string => red(bold(s));
-test({
+Deno.test({
name: "pass case",
fn(): void {
assertEquals({ a: 10 }, { a: 10 });
@@ -284,7 +282,7 @@ test({
},
});
-test({
+Deno.test({
name: "failed with number",
fn(): void {
assertThrows(
@@ -301,7 +299,7 @@ test({
},
});
-test({
+Deno.test({
name: "failed with number vs string",
fn(): void {
assertThrows(
@@ -317,7 +315,7 @@ test({
},
});
-test({
+Deno.test({
name: "failed with array",
fn(): void {
assertThrows(
@@ -334,7 +332,7 @@ test({
},
});
-test({
+Deno.test({
name: "failed with object",
fn(): void {
assertThrows(
@@ -355,7 +353,7 @@ test({
},
});
-test({
+Deno.test({
name: "strict pass case",
fn(): void {
assertStrictEquals(true, true);
@@ -372,7 +370,7 @@ test({
},
});
-test({
+Deno.test({
name: "strict failed with structure diff",
fn(): void {
assertThrows(
@@ -389,7 +387,7 @@ test({
},
});
-test({
+Deno.test({
name: "strict failed with reference diff",
fn(): void {
assertThrows(
diff --git a/std/testing/bench.ts b/std/testing/bench.ts
index a5e6490ac..366d6ec1b 100644
--- a/std/testing/bench.ts
+++ b/std/testing/bench.ts
@@ -1,8 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { deepAssign } from "../_util/deep_assign.ts";
-const { noColor } = Deno;
-
interface BenchmarkClock {
start: number;
stop: number;
@@ -98,11 +96,11 @@ export class BenchmarkRunError extends Error {
}
function red(text: string): string {
- return noColor ? text : `\x1b[31m${text}\x1b[0m`;
+ return Deno.noColor ? text : `\x1b[31m${text}\x1b[0m`;
}
function blue(text: string): string {
- return noColor ? text : `\x1b[34m${text}\x1b[0m`;
+ return Deno.noColor ? text : `\x1b[34m${text}\x1b[0m`;
}
function verifyOr1Run(runs?: number): number {
diff --git a/std/testing/bench_test.ts b/std/testing/bench_test.ts
index 0b101c22f..b6d64ab89 100644
--- a/std/testing/bench_test.ts
+++ b/std/testing/bench_test.ts
@@ -1,4 +1,3 @@
-const { test } = Deno;
import {
bench,
runBenchmarks,
@@ -14,7 +13,7 @@ import {
assertThrowsAsync,
} from "./asserts.ts";
-test({
+Deno.test({
name: "benching",
fn: async function (): Promise<void> {
@@ -101,7 +100,7 @@ test({
},
});
-test({
+Deno.test({
name: "Bench without name should throw",
fn() {
assertThrows(
@@ -114,7 +113,7 @@ test({
},
});
-test({
+Deno.test({
name: "Bench without stop should throw",
fn: async function (): Promise<void> {
await assertThrowsAsync(
@@ -131,7 +130,7 @@ test({
},
});
-test({
+Deno.test({
name: "Bench without start should throw",
fn: async function (): Promise<void> {
await assertThrowsAsync(
@@ -148,7 +147,7 @@ test({
},
});
-test({
+Deno.test({
name: "Bench with stop before start should throw",
fn: async function (): Promise<void> {
await assertThrowsAsync(
@@ -166,7 +165,7 @@ test({
},
});
-test({
+Deno.test({
name: "clearBenchmarks should clear all candidates",
fn: async function (): Promise<void> {
dummyBench("test");
@@ -179,7 +178,7 @@ test({
},
});
-test({
+Deno.test({
name: "clearBenchmarks with only as option",
fn: async function (): Promise<void> {
// to reset candidates
@@ -197,7 +196,7 @@ test({
},
});
-test({
+Deno.test({
name: "clearBenchmarks with skip as option",
fn: async function (): Promise<void> {
// to reset candidates
@@ -215,7 +214,7 @@ test({
},
});
-test({
+Deno.test({
name: "clearBenchmarks with only and skip as option",
fn: async function (): Promise<void> {
// to reset candidates
@@ -236,7 +235,7 @@ test({
},
});
-test({
+Deno.test({
name: "progressCallback of runBenchmarks",
fn: async function (): Promise<void> {
clearBenchmarks();
@@ -338,7 +337,7 @@ test({
},
});
-test({
+Deno.test({
name: "async progressCallback",
fn: async function (): Promise<void> {
clearBenchmarks();
diff --git a/std/testing/diff_test.ts b/std/testing/diff_test.ts
index 317dc0db8..072f39622 100644
--- a/std/testing/diff_test.ts
+++ b/std/testing/diff_test.ts
@@ -1,15 +1,14 @@
import diff from "./diff.ts";
import { assertEquals } from "../testing/asserts.ts";
-const { test } = Deno;
-test({
+Deno.test({
name: "empty",
fn(): void {
assertEquals(diff([], []), []);
},
});
-test({
+Deno.test({
name: '"a" vs "b"',
fn(): void {
assertEquals(diff(["a"], ["b"]), [
@@ -19,28 +18,28 @@ test({
},
});
-test({
+Deno.test({
name: '"a" vs "a"',
fn(): void {
assertEquals(diff(["a"], ["a"]), [{ type: "common", value: "a" }]);
},
});
-test({
+Deno.test({
name: '"a" vs ""',
fn(): void {
assertEquals(diff(["a"], []), [{ type: "removed", value: "a" }]);
},
});
-test({
+Deno.test({
name: '"" vs "a"',
fn(): void {
assertEquals(diff([], ["a"]), [{ type: "added", value: "a" }]);
},
});
-test({
+Deno.test({
name: '"a" vs "a, b"',
fn(): void {
assertEquals(diff(["a"], ["a", "b"]), [
@@ -50,7 +49,7 @@ test({
},
});
-test({
+Deno.test({
name: '"strength" vs "string"',
fn(): void {
assertEquals(diff(Array.from("strength"), Array.from("string")), [
@@ -67,7 +66,7 @@ test({
},
});
-test({
+Deno.test({
name: '"strength" vs ""',
fn(): void {
assertEquals(diff(Array.from("strength"), Array.from("")), [
@@ -83,7 +82,7 @@ test({
},
});
-test({
+Deno.test({
name: '"" vs "strength"',
fn(): void {
assertEquals(diff(Array.from(""), Array.from("strength")), [
@@ -99,7 +98,7 @@ test({
},
});
-test({
+Deno.test({
name: '"abc", "c" vs "abc", "bcd", "c"',
fn(): void {
assertEquals(diff(["abc", "c"], ["abc", "bcd", "c"]), [