diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2022-03-21 18:04:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-21 18:04:57 +0100 |
commit | c5792d6d1dcd2fe60e59e836015eac4f05a76039 (patch) | |
tree | c5b0585b308172f1b4721aefe978393da380040f /core/runtime.rs | |
parent | b4109375565c6d30d8ffb63f4083e0a430aee201 (diff) |
fix(core): variadic opSync/opAsync (#14062)
Diffstat (limited to 'core/runtime.rs')
-rw-r--r-- | core/runtime.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/core/runtime.rs b/core/runtime.rs index 5b6ce3998..dc279de88 100644 --- a/core/runtime.rs +++ b/core/runtime.rs @@ -2874,4 +2874,28 @@ assertEquals(1, notify_return_value); ) .is_err()); } + + #[test] + fn test_op_high_arity() { + #[op] + fn op_add_4( + x1: i64, + x2: i64, + x3: i64, + x4: i64, + ) -> Result<i64, anyhow::Error> { + Ok(x1 + x2 + x3 + x4) + } + + let ext = Extension::builder().ops(vec![op_add_4::decl()]).build(); + let mut runtime = JsRuntime::new(RuntimeOptions { + extensions: vec![ext], + ..Default::default() + }); + let r = runtime + .execute_script("test.js", "Deno.core.opSync('op_add_4', 1, 2, 3, 4)") + .unwrap(); + let scope = &mut runtime.handle_scope(); + assert_eq!(r.open(scope).integer_value(scope), Some(10)); + } } |