summaryrefslogtreecommitdiff
path: root/cli/tests/unit/ops_test.ts
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2024-01-31 22:39:56 +0100
committerGitHub <noreply@github.com>2024-01-31 22:39:56 +0100
commit13a91a69f87df98a31030d602f629a9a20f8a9c8 (patch)
treebce4f1cbcd51ad930815507b40ec33082b32145b /cli/tests/unit/ops_test.ts
parent163491f2378febc846190f64b60f199bd8e5ede8 (diff)
refactor: remove imported ops from Deno.core.ops (#22194)
This commit adds a list of ops to `runtime/99_main.js` that are currently relying on getting them from `Deno.core.ops`. All ops that are not present in the list are removed from `Deno.core.ops` on startup (they are imported from "virtual op module" - `ext:core/ops`) making them effectively inaccessible to user code. This change lowers the number of ops exposed to user code from 650 to around 260. This number should be gradually decreased in follow-up PRs.
Diffstat (limited to 'cli/tests/unit/ops_test.ts')
-rw-r--r--cli/tests/unit/ops_test.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/cli/tests/unit/ops_test.ts b/cli/tests/unit/ops_test.ts
new file mode 100644
index 000000000..e62d85728
--- /dev/null
+++ b/cli/tests/unit/ops_test.ts
@@ -0,0 +1,17 @@
+// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
+
+const EXPECTED_OP_COUNT = 157;
+
+Deno.test(function checkExposedOps() {
+ // @ts-ignore TS doesn't allow to index with symbol
+ const core = Deno[Deno.internal].core;
+ const opNames = Object.keys(core.ops);
+
+ if (opNames.length !== EXPECTED_OP_COUNT) {
+ throw new Error(
+ `Expected ${EXPECTED_OP_COUNT} ops, but got ${opNames.length}:\n${
+ opNames.join("\n")
+ }`,
+ );
+ }
+});