summaryrefslogtreecommitdiff
path: root/cli/tests/unit
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-01-24 18:54:10 +0100
committerGitHub <noreply@github.com>2023-01-24 18:54:10 +0100
commitabd96105300a7729a4d8eb69af2e81dd6307a163 (patch)
tree75b7556f876b2a2df3e22b905922dfb11572ef6d /cli/tests/unit
parent1084027d502d54ebf256c867fe85600b295d8a06 (diff)
refactor: remove Deno.core (#16881)
This commit removes "Deno.core" namespace. It is strictly private API that has no stability guarantees, we were supposed to remove it long time ago. Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
Diffstat (limited to 'cli/tests/unit')
-rw-r--r--cli/tests/unit/globals_test.ts18
-rw-r--r--cli/tests/unit/metrics_test.ts12
-rw-r--r--cli/tests/unit/opcall_test.ts15
-rw-r--r--cli/tests/unit/promise_hooks_test.ts4
-rw-r--r--cli/tests/unit/ref_unref_test.ts2
-rw-r--r--cli/tests/unit/text_encoding_test.ts4
6 files changed, 26 insertions, 29 deletions
diff --git a/cli/tests/unit/globals_test.ts b/cli/tests/unit/globals_test.ts
index cf7293bba..c63b28973 100644
--- a/cli/tests/unit/globals_test.ts
+++ b/cli/tests/unit/globals_test.ts
@@ -71,12 +71,8 @@ Deno.test(function webAssemblyExists() {
assert(typeof WebAssembly.compile === "function");
});
-declare global {
- namespace Deno {
- // deno-lint-ignore no-explicit-any, no-var
- var core: any;
- }
-}
+// @ts-ignore This is not publicly typed namespace, but it's there for sure.
+const core = Deno[Deno.internal].core;
Deno.test(function DenoNamespaceConfigurable() {
const desc = Object.getOwnPropertyDescriptor(globalThis, "Deno");
@@ -86,19 +82,19 @@ Deno.test(function DenoNamespaceConfigurable() {
});
Deno.test(function DenoCoreNamespaceIsImmutable() {
- const { print } = Deno.core;
+ const { print } = core;
try {
- Deno.core.print = 1;
+ core.print = 1;
} catch {
// pass
}
- assert(print === Deno.core.print);
+ assert(print === core.print);
try {
- delete Deno.core.print;
+ delete core.print;
} catch {
// pass
}
- assert(print === Deno.core.print);
+ assert(print === core.print);
});
Deno.test(async function windowQueueMicrotask() {
diff --git a/cli/tests/unit/metrics_test.ts b/cli/tests/unit/metrics_test.ts
index 5ada58b97..df2f1b2be 100644
--- a/cli/tests/unit/metrics_test.ts
+++ b/cli/tests/unit/metrics_test.ts
@@ -77,13 +77,15 @@ Deno.test(function metricsForOpCrates() {
assert(m1.opsCompleted > 0);
});
-// Test that op_names == Objects.keys(Deno.core.ops)
+// Test that op_names == Objects.keys(Deno[Deno.internal].core.ops)
// since building the per-op metrics depends on op_names being complete
Deno.test(function opNamesMatch() {
assertEquals(
- // @ts-ignore: Deno.core allowed
- Deno.core.opNames().sort(),
- // @ts-ignore: Deno.core allowed
- Object.keys(Deno.core.ops).sort().filter((name) => name !== "asyncOpsInfo"),
+ // @ts-ignore: Deno[Deno.internal].core allowed
+ Deno[Deno.internal].core.opNames().sort(),
+ // @ts-ignore: Deno[Deno.internal].core allowed
+ Object.keys(Deno[Deno.internal].core.ops).sort().filter((name) =>
+ name !== "asyncOpsInfo"
+ ),
);
});
diff --git a/cli/tests/unit/opcall_test.ts b/cli/tests/unit/opcall_test.ts
index 61c3c8849..3f4f4472c 100644
--- a/cli/tests/unit/opcall_test.ts
+++ b/cli/tests/unit/opcall_test.ts
@@ -22,17 +22,13 @@ Deno.test(async function sendAsyncStackTrace() {
}
});
-declare global {
- namespace Deno {
- // deno-lint-ignore no-explicit-any, no-var
- var core: any;
- }
-}
+// @ts-ignore This is not publicly typed namespace, but it's there for sure.
+const core = Deno[Deno.internal].core;
Deno.test(async function opsAsyncBadResource() {
try {
const nonExistingRid = 9999;
- await Deno.core.read(
+ await core.read(
nonExistingRid,
new Uint8Array(0),
);
@@ -46,7 +42,10 @@ Deno.test(async function opsAsyncBadResource() {
Deno.test(function opsSyncBadResource() {
try {
const nonExistingRid = 9999;
- Deno.core.ops.op_read_sync(nonExistingRid, new Uint8Array(0));
+ core.ops.op_read_sync(
+ nonExistingRid,
+ new Uint8Array(0),
+ );
} catch (e) {
if (!(e instanceof Deno.errors.BadResource)) {
throw e;
diff --git a/cli/tests/unit/promise_hooks_test.ts b/cli/tests/unit/promise_hooks_test.ts
index cbdb6320a..a0883d4b5 100644
--- a/cli/tests/unit/promise_hooks_test.ts
+++ b/cli/tests/unit/promise_hooks_test.ts
@@ -12,8 +12,8 @@ function monitorPromises(outputArray: string[]) {
return promiseIds.get(promise);
}
- // @ts-ignore: Deno.core allowed
- Deno.core.setPromiseHooks(
+ // @ts-ignore: Deno[Deno.internal].core allowed
+ Deno[Deno.internal].core.setPromiseHooks(
(promise: Promise<unknown>, parentPromise?: Promise<unknown>) => {
outputArray.push(
`init ${identify(promise)}` +
diff --git a/cli/tests/unit/ref_unref_test.ts b/cli/tests/unit/ref_unref_test.ts
index 7ce72a170..eea93b165 100644
--- a/cli/tests/unit/ref_unref_test.ts
+++ b/cli/tests/unit/ref_unref_test.ts
@@ -4,7 +4,7 @@ import { assertNotEquals, execCode } from "./test_util.ts";
Deno.test("[unrefOp] unref'ing invalid ops does not have effects", async () => {
const [statusCode, _] = await execCode(`
- Deno.core.unrefOp(-1);
+ Deno[Deno.internal].core.unrefOp(-1);
setTimeout(() => { throw new Error() }, 10)
`);
// Invalid unrefOp call doesn't affect exit condition of event loop
diff --git a/cli/tests/unit/text_encoding_test.ts b/cli/tests/unit/text_encoding_test.ts
index 78e4267a9..940dd9f74 100644
--- a/cli/tests/unit/text_encoding_test.ts
+++ b/cli/tests/unit/text_encoding_test.ts
@@ -264,8 +264,8 @@ Deno.test(function textEncoderShouldCoerceToString() {
});
Deno.test(function binaryEncode() {
- // @ts-ignore: Deno.core allowed
- const ops = Deno.core.ops;
+ // @ts-ignore: Deno[Deno.internal].core allowed
+ const ops = Deno[Deno.internal].core.ops;
function asBinaryString(bytes: Uint8Array): string {
return Array.from(bytes).map(
(v: number) => String.fromCodePoint(v),