From 92e8a292698f261651fe640510609713b0deed0c Mon Sep 17 00:00:00 2001 From: Aaron O'Mullan Date: Wed, 29 Dec 2021 15:21:42 +0100 Subject: cleanup(core): use Extensions to register ops (#13224) In examples and tests --- core/ops_json.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'core/ops_json.rs') 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>, msg: Option, @@ -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( "", -- cgit v1.2.3