mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 15:06:54 -05:00
21f1b2f62b
This commit provides basic polyfill for "node:test" module. Currently only top-level "test" function is polyfilled, all remaining functions from that module throw not implemented errors.
77 lines
1.4 KiB
Rust
77 lines
1.4 KiB
Rust
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
|
|
/// e.g. `is_builtin_node_module("assert")`
|
|
pub fn is_builtin_node_module(module_name: &str) -> bool {
|
|
SUPPORTED_BUILTIN_NODE_MODULES
|
|
.iter()
|
|
.any(|m| *m == module_name)
|
|
}
|
|
|
|
macro_rules! generate_builtin_node_module_lists {
|
|
($( $module_name:literal ,)+) => {
|
|
pub static SUPPORTED_BUILTIN_NODE_MODULES: &[&str] = &[
|
|
$(
|
|
$module_name,
|
|
)+
|
|
];
|
|
|
|
pub static SUPPORTED_BUILTIN_NODE_MODULES_WITH_PREFIX: &[&str] = &[
|
|
$(
|
|
concat!("node:", $module_name),
|
|
)+
|
|
];
|
|
};
|
|
}
|
|
|
|
// NOTE(bartlomieju): keep this list in sync with `ext/node/polyfills/01_require.js`
|
|
generate_builtin_node_module_lists! {
|
|
"assert",
|
|
"assert/strict",
|
|
"async_hooks",
|
|
"buffer",
|
|
"child_process",
|
|
"cluster",
|
|
"console",
|
|
"constants",
|
|
"crypto",
|
|
"dgram",
|
|
"diagnostics_channel",
|
|
"dns",
|
|
"dns/promises",
|
|
"domain",
|
|
"events",
|
|
"fs",
|
|
"fs/promises",
|
|
"http",
|
|
"http2",
|
|
"https",
|
|
"module",
|
|
"net",
|
|
"os",
|
|
"path",
|
|
"path/posix",
|
|
"path/win32",
|
|
"perf_hooks",
|
|
"process",
|
|
"punycode",
|
|
"querystring",
|
|
"readline",
|
|
"stream",
|
|
"stream/consumers",
|
|
"stream/promises",
|
|
"stream/web",
|
|
"string_decoder",
|
|
"sys",
|
|
"test",
|
|
"timers",
|
|
"timers/promises",
|
|
"tls",
|
|
"tty",
|
|
"url",
|
|
"util",
|
|
"util/types",
|
|
"v8",
|
|
"vm",
|
|
"worker_threads",
|
|
"zlib",
|
|
}
|