summaryrefslogtreecommitdiff
path: root/core/ops_json.rs
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2021-12-29 15:21:42 +0100
committerGitHub <noreply@github.com>2021-12-29 15:21:42 +0100
commit92e8a292698f261651fe640510609713b0deed0c (patch)
treed81b227339ca699f534467bf5a6d2118a8dfbe5b /core/ops_json.rs
parentb33bbf6af5749edb5d5e2e8de3b8d91416a29684 (diff)
cleanup(core): use Extensions to register ops (#13224)
In examples and tests
Diffstat (limited to 'core/ops_json.rs')
-rw-r--r--core/ops_json.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/core/ops_json.rs b/core/ops_json.rs
index ad4aeeb47..b7e833129 100644
--- a/core/ops_json.rs
+++ b/core/ops_json.rs
@@ -123,8 +123,6 @@ mod tests {
#[tokio::test]
async fn op_async_stack_trace() {
- let mut runtime = crate::JsRuntime::new(Default::default());
-
async fn op_throw(
_state: Rc<RefCell<OpState>>,
msg: Option<String>,
@@ -134,8 +132,15 @@ mod tests {
Err(crate::error::generic_error("foo"))
}
- runtime.register_op("op_throw", op_async(op_throw));
- runtime.sync_ops_cache();
+ let ext = crate::Extension::builder()
+ .ops(vec![("op_throw", op_async(op_throw))])
+ .build();
+
+ let mut runtime = crate::JsRuntime::new(crate::RuntimeOptions {
+ extensions: vec![ext],
+ ..Default::default()
+ });
+
runtime
.execute_script(
"<init>",