diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2020-06-12 20:23:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-12 15:23:38 -0400 |
commit | 1fff6f55c3ba98a10018c6d374795e612061e9b6 (patch) | |
tree | 12074b6d44736b11513d857e437f9e30a6bf65a4 /std/path | |
parent | 26bf56afdaf16634ffbaa23684faf3a44cc10f62 (diff) |
refactor: Don't destructure the Deno namespace (#6268)
Diffstat (limited to 'std/path')
-rw-r--r-- | std/path/_globrex_test.ts | 38 | ||||
-rw-r--r-- | std/path/basename_test.ts | 6 | ||||
-rw-r--r-- | std/path/common_test.ts | 9 | ||||
-rw-r--r-- | std/path/dirname_test.ts | 6 | ||||
-rw-r--r-- | std/path/extname_test.ts | 6 | ||||
-rw-r--r-- | std/path/glob_test.ts | 25 | ||||
-rw-r--r-- | std/path/isabsolute_test.ts | 6 | ||||
-rw-r--r-- | std/path/join_test.ts | 5 | ||||
-rw-r--r-- | std/path/parse_format_test.ts | 18 | ||||
-rw-r--r-- | std/path/relative_test.ts | 6 | ||||
-rw-r--r-- | std/path/resolve_test.ts | 10 | ||||
-rw-r--r-- | std/path/zero_length_strings_test.ts | 14 |
12 files changed, 63 insertions, 86 deletions
diff --git a/std/path/_globrex_test.ts b/std/path/_globrex_test.ts index 2974b4719..67a58cc64 100644 --- a/std/path/_globrex_test.ts +++ b/std/path/_globrex_test.ts @@ -1,8 +1,6 @@ // This file is ported from globrex@0.1.2 // MIT License // Copyright (c) 2018 Terkel Gjervig Nielsen - -const { test } = Deno; import { assertEquals } from "../testing/asserts.ts"; import { GlobrexOptions, globrex } from "./_globrex.ts"; @@ -27,7 +25,7 @@ function match( return !!match; } -test({ +Deno.test({ name: "globrex: standard", fn(): void { const res = globrex("*.js"); @@ -37,7 +35,7 @@ test({ }, }); -test({ +Deno.test({ name: "globrex: Standard * matching", fn(): void { t.equal(match("*", "foo"), true, "match everything"); @@ -67,7 +65,7 @@ test({ }, }); -test({ +Deno.test({ name: "globrex: advance * matching", fn(): void { t.equal( @@ -178,7 +176,7 @@ test({ }, }); -test({ +Deno.test({ name: "globrex: ? match one character, no more and no less", fn(): void { t.equal(match("f?o", "foo", { extended: true }), true); @@ -218,7 +216,7 @@ test({ }, }); -test({ +Deno.test({ name: "globrex: [] match a character range", fn(): void { t.equal(match("fo[oz]", "foo", { extended: true }), true); @@ -249,7 +247,7 @@ test({ }, }); -test({ +Deno.test({ name: "globrex: [] extended character ranges", fn(): void { t.equal( @@ -307,7 +305,7 @@ test({ }, }); -test({ +Deno.test({ name: "globrex: {} match a choice of different substrings", fn(): void { t.equal(match("foo{bar,baaz}", "foobaaz", { extended: true }), true); @@ -355,7 +353,7 @@ test({ }, }); -test({ +Deno.test({ name: "globrex: complex extended matches", fn(): void { t.equal( @@ -447,7 +445,7 @@ test({ }, }); -test({ +Deno.test({ name: "globrex: standard globstar", fn(): void { const tester = (globstar: boolean): void => { @@ -482,7 +480,7 @@ test({ }, }); -test({ +Deno.test({ name: "globrex: remaining chars should match themself", fn(): void { const tester = (globstar: boolean): void => { @@ -499,7 +497,7 @@ test({ }, }); -test({ +Deno.test({ name: "globrex: globstar advance testing", fn(): void { t.equal(match("/foo/*", "/foo/bar.txt", { globstar: true }), true); @@ -639,7 +637,7 @@ test({ }, }); -test({ +Deno.test({ name: "globrex: extended extglob ?", fn(): void { t.equal(match("(foo).txt", "(foo).txt", { extended: true }), true); @@ -692,7 +690,7 @@ test({ }, }); -test({ +Deno.test({ name: "globrex: extended extglob *", fn(): void { t.equal(match("*(foo).txt", "foo.txt", { extended: true }), true); @@ -729,7 +727,7 @@ test({ }, }); -test({ +Deno.test({ name: "globrex: extended extglob +", fn(): void { t.equal(match("+(foo).txt", "foo.txt", { extended: true }), true); @@ -739,7 +737,7 @@ test({ }, }); -test({ +Deno.test({ name: "globrex: extended extglob @", fn(): void { t.equal(match("@(foo).txt", "foo.txt", { extended: true }), true); @@ -760,7 +758,7 @@ test({ }, }); -test({ +Deno.test({ name: "globrex: extended extglob !", fn(): void { t.equal(match("!(boo).txt", "foo.txt", { extended: true }), true); @@ -777,7 +775,7 @@ test({ }, }); -test({ +Deno.test({ name: "globrex: strict", fn(): void { t.equal(match("foo//bar.txt", "foo/bar.txt"), true); @@ -786,7 +784,7 @@ test({ }, }); -test({ +Deno.test({ name: "globrex: stress testing", fn(): void { t.equal( diff --git a/std/path/basename_test.ts b/std/path/basename_test.ts index 8ec70eb08..b0694de20 100644 --- a/std/path/basename_test.ts +++ b/std/path/basename_test.ts @@ -1,11 +1,9 @@ // Copyright the Browserify authors. MIT License. // Ported from https://github.com/browserify/path-browserify/ - -const { test } = Deno; import { assertEquals } from "../testing/asserts.ts"; import * as path from "./mod.ts"; -test("basename", function () { +Deno.test("basename", function () { assertEquals(path.basename(".js", ".js"), ""); assertEquals(path.basename(""), ""); assertEquals(path.basename("/dir/basename.ext"), "basename.ext"); @@ -50,7 +48,7 @@ test("basename", function () { ); }); -test("basenameWin32", function () { +Deno.test("basenameWin32", function () { assertEquals(path.win32.basename("\\dir\\basename.ext"), "basename.ext"); assertEquals(path.win32.basename("\\basename.ext"), "basename.ext"); assertEquals(path.win32.basename("basename.ext"), "basename.ext"); diff --git a/std/path/common_test.ts b/std/path/common_test.ts index 63dba38b8..921cf1c99 100644 --- a/std/path/common_test.ts +++ b/std/path/common_test.ts @@ -1,11 +1,8 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. - -const { test } = Deno; import { assertEquals } from "../testing/asserts.ts"; - import { common } from "./mod.ts"; -test({ +Deno.test({ name: "path - common - basic usage", fn() { const actual = common( @@ -20,7 +17,7 @@ test({ }, }); -test({ +Deno.test({ name: "path - common - no shared", fn() { const actual = common( @@ -31,7 +28,7 @@ test({ }, }); -test({ +Deno.test({ name: "path - common - windows sep", fn() { const actual = common( diff --git a/std/path/dirname_test.ts b/std/path/dirname_test.ts index a00c8bc46..bdf3391a9 100644 --- a/std/path/dirname_test.ts +++ b/std/path/dirname_test.ts @@ -1,11 +1,9 @@ // Copyright the Browserify authors. MIT License. // Ported from https://github.com/browserify/path-browserify/ - -const { test } = Deno; import { assertEquals } from "../testing/asserts.ts"; import * as path from "./mod.ts"; -test("dirname", function () { +Deno.test("dirname", function () { assertEquals(path.posix.dirname("/a/b/"), "/a"); assertEquals(path.posix.dirname("/a/b"), "/a"); assertEquals(path.posix.dirname("/a"), "/"); @@ -16,7 +14,7 @@ test("dirname", function () { assertEquals(path.posix.dirname("foo"), "."); }); -test("dirnameWin32", function () { +Deno.test("dirnameWin32", function () { assertEquals(path.win32.dirname("c:\\"), "c:\\"); assertEquals(path.win32.dirname("c:\\foo"), "c:\\"); assertEquals(path.win32.dirname("c:\\foo\\"), "c:\\"); diff --git a/std/path/extname_test.ts b/std/path/extname_test.ts index d5c54a6de..7e1abf4bc 100644 --- a/std/path/extname_test.ts +++ b/std/path/extname_test.ts @@ -1,7 +1,5 @@ // Copyright the Browserify authors. MIT License. // Ported from https://github.com/browserify/path-browserify/ - -const { test } = Deno; import { assertEquals } from "../testing/asserts.ts"; import * as path from "./mod.ts"; @@ -52,7 +50,7 @@ const pairs = [ ["file.//", "."], ]; -test("extname", function () { +Deno.test("extname", function () { pairs.forEach(function (p) { const input = p[0]; const expected = p[1]; @@ -70,7 +68,7 @@ test("extname", function () { assertEquals(path.posix.extname("file.\\\\"), ".\\\\"); }); -test("extnameWin32", function () { +Deno.test("extnameWin32", function () { pairs.forEach(function (p) { const input = p[0].replace(slashRE, "\\"); const expected = p[1]; diff --git a/std/path/glob_test.ts b/std/path/glob_test.ts index 1ab3d9240..1c90e765a 100644 --- a/std/path/glob_test.ts +++ b/std/path/glob_test.ts @@ -1,10 +1,9 @@ -const { mkdir, test } = Deno; import { assert, assertEquals } from "../testing/asserts.ts"; import { testWalk, touch, walkArray } from "../fs/walk_test.ts"; import { globToRegExp, isGlob, joinGlobs, normalizeGlob } from "./glob.ts"; import { SEP, join } from "./mod.ts"; -test({ +Deno.test({ name: "glob: glob to regex", fn(): void { assertEquals(globToRegExp("unicorn.*") instanceof RegExp, true); @@ -47,8 +46,8 @@ test({ testWalk( async (d: string): Promise<void> => { - await mkdir(d + "/a"); - await mkdir(d + "/b"); + await Deno.mkdir(d + "/a"); + await Deno.mkdir(d + "/b"); await touch(d + "/a/x.ts"); await touch(d + "/b/z.ts"); await touch(d + "/b/z.js"); @@ -65,8 +64,8 @@ testWalk( testWalk( async (d: string): Promise<void> => { - await mkdir(d + "/a"); - await mkdir(d + "/a/yo"); + await Deno.mkdir(d + "/a"); + await Deno.mkdir(d + "/a/yo"); await touch(d + "/a/yo/x.ts"); }, async function globInWalkFolderWildcard(): Promise<void> { @@ -85,10 +84,10 @@ testWalk( testWalk( async (d: string): Promise<void> => { - await mkdir(d + "/a"); - await mkdir(d + "/a/unicorn"); - await mkdir(d + "/a/deno"); - await mkdir(d + "/a/raptor"); + await Deno.mkdir(d + "/a"); + await Deno.mkdir(d + "/a/unicorn"); + await Deno.mkdir(d + "/a/deno"); + await Deno.mkdir(d + "/a/raptor"); await touch(d + "/a/raptor/x.ts"); await touch(d + "/a/deno/x.ts"); await touch(d + "/a/unicorn/x.ts"); @@ -124,7 +123,7 @@ testWalk( } ); -test({ +Deno.test({ name: "isGlob: pattern to test", fn(): void { // should be true if valid glob pattern @@ -239,10 +238,10 @@ test({ }, }); -test("normalizeGlobGlobstar", function (): void { +Deno.test("normalizeGlobGlobstar", function (): void { assertEquals(normalizeGlob(`**${SEP}..`, { globstar: true }), `**${SEP}..`); }); -test("joinGlobsGlobstar", function (): void { +Deno.test("joinGlobsGlobstar", function (): void { assertEquals(joinGlobs(["**", ".."], { globstar: true }), `**${SEP}..`); }); diff --git a/std/path/isabsolute_test.ts b/std/path/isabsolute_test.ts index b1614d3de..88ed54417 100644 --- a/std/path/isabsolute_test.ts +++ b/std/path/isabsolute_test.ts @@ -1,18 +1,16 @@ // Copyright the Browserify authors. MIT License. // Ported from https://github.com/browserify/path-browserify/ - -const { test } = Deno; import { assertEquals } from "../testing/asserts.ts"; import * as path from "./mod.ts"; -test("isAbsolute", function () { +Deno.test("isAbsolute", function () { assertEquals(path.posix.isAbsolute("/home/foo"), true); assertEquals(path.posix.isAbsolute("/home/foo/.."), true); assertEquals(path.posix.isAbsolute("bar/"), false); assertEquals(path.posix.isAbsolute("./baz"), false); }); -test("isAbsoluteWin32", function () { +Deno.test("isAbsoluteWin32", function () { assertEquals(path.win32.isAbsolute("/"), true); assertEquals(path.win32.isAbsolute("//"), true); assertEquals(path.win32.isAbsolute("//server"), true); diff --git a/std/path/join_test.ts b/std/path/join_test.ts index 6e70eba5b..b7311406f 100644 --- a/std/path/join_test.ts +++ b/std/path/join_test.ts @@ -1,4 +1,3 @@ -const { test } = Deno; import { assertEquals } from "../testing/asserts.ts"; import * as path from "./mod.ts"; @@ -106,7 +105,7 @@ const windowsJoinTests = [ [["c:", "file"], "c:\\file"], ]; -test("join", function () { +Deno.test("join", function () { joinTests.forEach(function (p) { const _p = p[0] as string[]; const actual = path.posix.join.apply(null, _p); @@ -114,7 +113,7 @@ test("join", function () { }); }); -test("joinWin32", function () { +Deno.test("joinWin32", function () { joinTests.forEach(function (p) { const _p = p[0] as string[]; const actual = path.win32.join.apply(null, _p).replace(backslashRE, "/"); diff --git a/std/path/parse_format_test.ts b/std/path/parse_format_test.ts index bc58679cf..80692a84d 100644 --- a/std/path/parse_format_test.ts +++ b/std/path/parse_format_test.ts @@ -1,12 +1,10 @@ // Copyright the Browserify authors. MIT License. // Ported from https://github.com/browserify/path-browserify/ - -// TODO(kt3k): fix any types in this file - -const { test } = Deno; import { assertEquals } from "../testing/asserts.ts"; import * as path from "./mod.ts"; +// TODO(kt3k): fix any types in this file + const winPaths = [ // [path, root] ["C:\\path\\dir\\index.html", "C:\\"], @@ -116,20 +114,20 @@ function checkFormat(path: any, testCases: unknown[][]): void { }); } -test("parseWin32", function () { +Deno.test("parseWin32", function () { checkParseFormat(path.win32, winPaths); checkSpecialCaseParseFormat(path.win32, winSpecialCaseParseTests); }); -test("parse", function () { +Deno.test("parse", function () { checkParseFormat(path.posix, unixPaths); }); -test("formatWin32", function () { +Deno.test("formatWin32", function () { checkFormat(path.win32, winSpecialCaseFormatTests); }); -test("format", function () { +Deno.test("format", function () { checkFormat(path.posix, unixSpecialCaseFormatTests); }); @@ -165,7 +163,7 @@ const posixTrailingTests = [ ], ]; -test("parseTrailingWin32", function () { +Deno.test("parseTrailingWin32", function () { windowsTrailingTests.forEach(function (p) { const actual = path.win32.parse(p[0] as string); const expected = p[1]; @@ -173,7 +171,7 @@ test("parseTrailingWin32", function () { }); }); -test("parseTrailing", function () { +Deno.test("parseTrailing", function () { posixTrailingTests.forEach(function (p) { const actual = path.posix.parse(p[0] as string); const expected = p[1]; diff --git a/std/path/relative_test.ts b/std/path/relative_test.ts index 18b6930e8..e00e16d73 100644 --- a/std/path/relative_test.ts +++ b/std/path/relative_test.ts @@ -1,7 +1,5 @@ // Copyright the Browserify authors. MIT License. // Ported from https://github.com/browserify/path-browserify/ - -const { test } = Deno; import { assertEquals } from "../testing/asserts.ts"; import * as path from "./mod.ts"; @@ -50,7 +48,7 @@ const relativeTests = { ], }; -test("relative", function () { +Deno.test("relative", function () { relativeTests.posix.forEach(function (p) { const expected = p[2]; const actual = path.posix.relative(p[0], p[1]); @@ -58,7 +56,7 @@ test("relative", function () { }); }); -test("relativeWin32", function () { +Deno.test("relativeWin32", function () { relativeTests.win32.forEach(function (p) { const expected = p[2]; const actual = path.win32.relative(p[0], p[1]); diff --git a/std/path/resolve_test.ts b/std/path/resolve_test.ts index 36a537b7a..dec032f47 100644 --- a/std/path/resolve_test.ts +++ b/std/path/resolve_test.ts @@ -1,7 +1,5 @@ // Copyright the Browserify authors. MIT License. // Ported from https://github.com/browserify/path-browserify/ - -const { cwd, test } = Deno; import { assertEquals } from "../testing/asserts.ts"; import * as path from "./mod.ts"; @@ -28,13 +26,13 @@ const posixTests = [ [["/var/lib", "../", "file/"], "/var/file"], [["/var/lib", "/../", "file/"], "/file"], - [["a/b/c/", "../../.."], cwd()], - [["."], cwd()], + [["a/b/c/", "../../.."], Deno.cwd()], + [["."], Deno.cwd()], [["/some/dir", ".", "/absolute/"], "/absolute"], [["/foo/tmp.3/", "../tmp.3/cycles/root.js"], "/foo/tmp.3/cycles/root.js"], ]; -test("resolve", function () { +Deno.test("resolve", function () { posixTests.forEach(function (p) { const _p = p[0] as string[]; const actual = path.posix.resolve.apply(null, _p); @@ -42,7 +40,7 @@ test("resolve", function () { }); }); -test("resolveWin32", function () { +Deno.test("resolveWin32", function () { windowsTests.forEach(function (p) { const _p = p[0] as string[]; const actual = path.win32.resolve.apply(null, _p); diff --git a/std/path/zero_length_strings_test.ts b/std/path/zero_length_strings_test.ts index 771395a8c..e2ec466a5 100644 --- a/std/path/zero_length_strings_test.ts +++ b/std/path/zero_length_strings_test.ts @@ -1,13 +1,11 @@ // Copyright the Browserify authors. MIT License. // Ported from https://github.com/browserify/path-browserify/ - -const { cwd, test } = Deno; import { assertEquals } from "../testing/asserts.ts"; import * as path from "./mod.ts"; -const pwd = cwd(); +const pwd = Deno.cwd(); -test("joinZeroLength", function () { +Deno.test("joinZeroLength", function () { // join will internally ignore all the zero-length strings and it will return // '.' if the joined string is a zero-length string. assertEquals(path.posix.join(""), "."); @@ -18,28 +16,28 @@ test("joinZeroLength", function () { assertEquals(path.join(pwd, ""), pwd); }); -test("normalizeZeroLength", function () { +Deno.test("normalizeZeroLength", function () { // normalize will return '.' if the input is a zero-length string assertEquals(path.posix.normalize(""), "."); if (path.win32) assertEquals(path.win32.normalize(""), "."); assertEquals(path.normalize(pwd), pwd); }); -test("isAbsoluteZeroLength", function () { +Deno.test("isAbsoluteZeroLength", function () { // Since '' is not a valid path in any of the common environments, // return false assertEquals(path.posix.isAbsolute(""), false); if (path.win32) assertEquals(path.win32.isAbsolute(""), false); }); -test("resolveZeroLength", function () { +Deno.test("resolveZeroLength", function () { // resolve, internally ignores all the zero-length strings and returns the // current working directory assertEquals(path.resolve(""), pwd); assertEquals(path.resolve("", ""), pwd); }); -test("relativeZeroLength", function () { +Deno.test("relativeZeroLength", function () { // relative, internally calls resolve. So, '' is actually the current // directory assertEquals(path.relative("", pwd), ""); |