summaryrefslogtreecommitdiff
path: root/core/runtime.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-04-21 15:22:45 +0200
committerGitHub <noreply@github.com>2023-04-21 15:22:45 +0200
commit1d447cb7c3295941be85a05b455f45d89e119667 (patch)
tree118635a7bcb8e75fbe067a16e351711f946ebd75 /core/runtime.rs
parent4e944dea1d6ad6cc819cbef278b59923eeaa2287 (diff)
refactor(core): remove ops from Deno.core.ops that are disabled (#18793)
This commit changes how "disabled" ops behave. Instead of using "void" functions under the hood, they now explicitly throw errors saying that a given op doesn't exist.
Diffstat (limited to 'core/runtime.rs')
-rw-r--r--core/runtime.rs23
1 files changed, 6 insertions, 17 deletions
diff --git a/core/runtime.rs b/core/runtime.rs
index 27fd82496..923caaea9 100644
--- a/core/runtime.rs
+++ b/core/runtime.rs
@@ -15,8 +15,6 @@ use crate::modules::ModuleId;
use crate::modules::ModuleLoadId;
use crate::modules::ModuleLoader;
use crate::modules::ModuleMap;
-use crate::op_void_async;
-use crate::op_void_sync;
use crate::ops::*;
use crate::realm::ContextState;
use crate::realm::JsRealm;
@@ -773,16 +771,6 @@ impl JsRuntime {
name: d.name,
..macroware(d)
})
- .map(|op| match op.enabled {
- true => op,
- false => OpDecl {
- v8_fn_ptr: match op.is_async {
- true => op_void_async::v8_fn_ptr as _,
- false => op_void_sync::v8_fn_ptr as _,
- },
- ..op
- },
- })
.collect()
}
@@ -4223,11 +4211,12 @@ Deno.core.opAsync("op_async_serialize_object_with_numbers_as_keys", {
extensions: vec![test_ext::init_ops()],
..Default::default()
});
- let r = runtime
+ let err = runtime
.execute_script_static("test.js", "Deno.core.ops.op_foo()")
- .unwrap();
- let scope = &mut runtime.handle_scope();
- assert!(r.open(scope).is_undefined());
+ .unwrap_err();
+ assert!(err
+ .to_string()
+ .contains("TypeError: Deno.core.ops.op_foo is not a function"));
}
#[test]
@@ -4327,7 +4316,7 @@ Deno.core.opAsync("op_async_serialize_object_with_numbers_as_keys", {
if (Deno.core.ops.op_foo() !== 42) {
throw new Error("Exptected op_foo() === 42");
}
- if (Deno.core.ops.op_bar() !== undefined) {
+ if (typeof Deno.core.ops.op_bar !== "undefined") {
throw new Error("Expected op_bar to be disabled")
}
"#,