deno/cli/tests/unit/ops_test.ts
Bartek Iwańczuk 13a91a69f8
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.
2024-01-31 22:39:56 +01:00

18 lines
476 B
TypeScript

// 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")
}`,
);
}
});