diff options
author | Asher Gomez <ashersaupingomez@gmail.com> | 2024-09-12 11:30:12 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-12 11:30:12 +1000 |
commit | 3285801429eb7a40e022b571b7e3007c3e60250c (patch) | |
tree | 2ddd6c9757a9753b4cd0c21cd93f68937b79b1ab /tests/unit | |
parent | 57556ade8c128aeea7340d463b35c86afe1fb4f7 (diff) |
test: remove `DENO_FUTURE` (#25587)
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/fetch_test.ts | 3 | ||||
-rw-r--r-- | tests/unit/files_test.ts | 3 | ||||
-rw-r--r-- | tests/unit/globals_test.ts | 41 | ||||
-rw-r--r-- | tests/unit/serve_test.ts | 3 | ||||
-rw-r--r-- | tests/unit/test_util.ts | 3 | ||||
-rw-r--r-- | tests/unit/timers_test.ts | 57 | ||||
-rw-r--r-- | tests/unit/tls_test.ts | 5 | ||||
-rw-r--r-- | tests/unit/tty_test.ts | 13 |
8 files changed, 11 insertions, 117 deletions
diff --git a/tests/unit/fetch_test.ts b/tests/unit/fetch_test.ts index 35517911c..48cde90ab 100644 --- a/tests/unit/fetch_test.ts +++ b/tests/unit/fetch_test.ts @@ -9,7 +9,6 @@ import { assertStringIncludes, assertThrows, delay, - DENO_FUTURE, fail, unimplemented, } from "./test_util.ts"; @@ -1359,7 +1358,7 @@ Deno.test( ); Deno.test( - { permissions: { read: true, net: true }, ignore: DENO_FUTURE }, + { permissions: { read: true, net: true } }, async function fetchCustomClientPrivateKey(): Promise< void > { diff --git a/tests/unit/files_test.ts b/tests/unit/files_test.ts index 3bbfc3855..a847104c2 100644 --- a/tests/unit/files_test.ts +++ b/tests/unit/files_test.ts @@ -5,7 +5,6 @@ import { assertEquals, assertRejects, assertThrows, - DENO_FUTURE, } from "./test_util.ts"; import { copy } from "@std/io/copy"; @@ -21,7 +20,7 @@ Deno.test(function filesStdioFileDescriptors() { }); Deno.test( - { ignore: DENO_FUTURE, permissions: { read: true } }, + { permissions: { read: true } }, async function filesCopyToStdout() { const filename = "tests/testdata/assets/fixture.json"; using file = await Deno.open(filename); diff --git a/tests/unit/globals_test.ts b/tests/unit/globals_test.ts index 7e648d38d..45a045835 100644 --- a/tests/unit/globals_test.ts +++ b/tests/unit/globals_test.ts @@ -1,12 +1,10 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -// deno-lint-ignore-file no-window-prefix no-window import { assert, assertEquals, assertRejects, assertThrows, - DENO_FUTURE, } from "./test_util.ts"; Deno.test(function globalThisExists() { @@ -20,34 +18,18 @@ Deno.test(function noInternalGlobals() { } }); -Deno.test({ ignore: DENO_FUTURE }, function windowExists() { - assert(window != null); -}); - Deno.test(function selfExists() { assert(self != null); }); -Deno.test({ ignore: DENO_FUTURE }, function windowWindowExists() { - assert(window.window === window); -}); - -Deno.test({ ignore: DENO_FUTURE }, function windowSelfExists() { - assert(window.self === window); -}); - -Deno.test({ ignore: DENO_FUTURE }, function globalThisEqualsWindow() { - assert(globalThis === window); +Deno.test(function globalThisWindowEqualsUndefined() { + assert(globalThis.window === undefined); }); Deno.test(function globalThisEqualsSelf() { assert(globalThis === self); }); -Deno.test({ ignore: DENO_FUTURE }, function globalThisInstanceofWindow() { - assert(globalThis instanceof Window); -}); - Deno.test(function globalThisConstructorLength() { assert(globalThis.constructor.length === 0); }); @@ -66,10 +48,6 @@ Deno.test(function DenoNamespaceExists() { assert(Deno != null); }); -Deno.test({ ignore: DENO_FUTURE }, function DenoNamespaceEqualsWindowDeno() { - assert(Deno === window.Deno); -}); - Deno.test(function DenoNamespaceIsNotFrozen() { assert(!Object.isFrozen(Deno)); }); @@ -120,11 +98,7 @@ Deno.test(async function windowQueueMicrotask() { res(); }; }); - if (DENO_FUTURE) { - globalThis.queueMicrotask(resolve1!); - } else { - window.queueMicrotask(resolve1!); - } + globalThis.queueMicrotask(resolve1!); setTimeout(resolve2!, 0); await p1; await p2; @@ -143,18 +117,9 @@ Deno.test(function webApiGlobalThis() { Deno.test(function windowNameIsDefined() { assertEquals(typeof globalThis.name, "string"); assertEquals(name, ""); - if (!DENO_FUTURE) { - assertEquals(window.name, name); - } name = "foobar"; - if (!DENO_FUTURE) { - assertEquals(window.name, "foobar"); - } assertEquals(name, "foobar"); name = ""; - if (!DENO_FUTURE) { - assertEquals(window.name, ""); - } assertEquals(name, ""); }); diff --git a/tests/unit/serve_test.ts b/tests/unit/serve_test.ts index 13f8ba867..4a19d8df2 100644 --- a/tests/unit/serve_test.ts +++ b/tests/unit/serve_test.ts @@ -12,7 +12,6 @@ import { assertThrows, curlRequest, curlRequestWithStdErr, - DENO_FUTURE, execCode, execCode3, fail, @@ -20,7 +19,7 @@ import { } from "./test_util.ts"; // Since these tests may run in parallel, ensure this port is unique to this file -const servePort = DENO_FUTURE ? 4511 : 4502; +const servePort = 4511; const { upgradeHttpRaw, diff --git a/tests/unit/test_util.ts b/tests/unit/test_util.ts index 3f41b90a2..a987cb542 100644 --- a/tests/unit/test_util.ts +++ b/tests/unit/test_util.ts @@ -25,9 +25,6 @@ export { delay } from "@std/async/delay"; export { readLines } from "@std/io/read-lines"; export { parseArgs } from "@std/cli/parse-args"; -// TODO(2.0): remove this and all the tests that depend on it. -export const DENO_FUTURE = true; - export function pathToAbsoluteFileUrl(path: string): URL { path = resolve(path); diff --git a/tests/unit/timers_test.ts b/tests/unit/timers_test.ts index 212f197cc..580d8c524 100644 --- a/tests/unit/timers_test.ts +++ b/tests/unit/timers_test.ts @@ -7,7 +7,6 @@ import { assertEquals, assertNotEquals, delay, - DENO_FUTURE, execCode, unreachable, } from "./test_util.ts"; @@ -312,62 +311,10 @@ Deno.test(async function timeoutCallbackThis() { }; setTimeout(obj.foo, 1); await promise; - if (!DENO_FUTURE) { - assertEquals(capturedThis, window); - } else { - assertEquals(capturedThis, globalThis); - } -}); - -Deno.test({ ignore: DENO_FUTURE }, async function timeoutBindThis() { - const thisCheckPassed = [null, undefined, globalThis, window]; - - const thisCheckFailed = [ - 0, - "", - true, - false, - {}, - [], - "foo", - () => {}, - Object.prototype, - ]; - - for (const thisArg of thisCheckPassed) { - const { promise, resolve } = Promise.withResolvers<void>(); - let hasThrown = 0; - try { - setTimeout.call(thisArg, () => resolve(), 1); - hasThrown = 1; - } catch (err) { - if (err instanceof TypeError) { - hasThrown = 2; - } else { - hasThrown = 3; - } - } - await promise; - assertEquals(hasThrown, 1); - } - - for (const thisArg of thisCheckFailed) { - let hasThrown = 0; - try { - setTimeout.call(thisArg, () => {}, 1); - hasThrown = 1; - } catch (err) { - if (err instanceof TypeError) { - hasThrown = 2; - } else { - hasThrown = 3; - } - } - assertEquals(hasThrown, 2); - } + assertEquals(capturedThis, globalThis); }); -Deno.test({ ignore: !DENO_FUTURE }, async function timeoutBindThis() { +Deno.test(async function timeoutBindThis() { const thisCheckPassed = [null, undefined, globalThis]; const thisCheckFailed = [ diff --git a/tests/unit/tls_test.ts b/tests/unit/tls_test.ts index 0f6ffc15f..aba4d254c 100644 --- a/tests/unit/tls_test.ts +++ b/tests/unit/tls_test.ts @@ -6,7 +6,6 @@ import { assertRejects, assertStrictEquals, assertThrows, - DENO_FUTURE, } from "./test_util.ts"; import { BufReader, BufWriter } from "@std/io"; import { readAll } from "@std/io/read-all"; @@ -1042,7 +1041,7 @@ Deno.test( ); Deno.test( - { permissions: { read: true, net: true }, ignore: DENO_FUTURE }, + { permissions: { read: true, net: true } }, async function connectTLSBadCertKey(): Promise<void> { await assertRejects(async () => { await Deno.connectTls({ @@ -1074,7 +1073,7 @@ Deno.test( ); Deno.test( - { permissions: { read: true, net: true }, ignore: DENO_FUTURE }, + { permissions: { read: true, net: true } }, async function connectTLSNotKey(): Promise<void> { await assertRejects(async () => { await Deno.connectTls({ diff --git a/tests/unit/tty_test.ts b/tests/unit/tty_test.ts index 4183fe530..1d29a0b70 100644 --- a/tests/unit/tty_test.ts +++ b/tests/unit/tty_test.ts @@ -2,7 +2,7 @@ // deno-lint-ignore-file no-deprecated-deno-api -import { assert, DENO_FUTURE } from "./test_util.ts"; +import { assert } from "./test_util.ts"; // Note tests for Deno.stdin.setRaw is in integration tests. @@ -15,17 +15,6 @@ Deno.test(function consoleSize() { assert(typeof result.rows !== "undefined"); }); -Deno.test( - { ignore: DENO_FUTURE, permissions: { read: true } }, - function isatty() { - // CI not under TTY, so cannot test stdin/stdout/stderr. - const f = Deno.openSync("tests/testdata/assets/hello.txt"); - // @ts-ignore `Deno.isatty()` was soft-removed in Deno 2. - assert(!Deno.isatty(f.rid)); - f.close(); - }, -); - Deno.test(function isattyError() { let caught = false; try { |