diff options
Diffstat (limited to 'ops/tests')
-rw-r--r-- | ops/tests/01_fast_callback_options.rs | 11 | ||||
-rw-r--r-- | ops/tests/compile_fail/unsupported.rs | 7 | ||||
-rw-r--r-- | ops/tests/compile_fail/unsupported.stderr | 20 | ||||
-rw-r--r-- | ops/tests/mod.rs | 1 |
4 files changed, 37 insertions, 2 deletions
diff --git a/ops/tests/01_fast_callback_options.rs b/ops/tests/01_fast_callback_options.rs new file mode 100644 index 000000000..815d9262c --- /dev/null +++ b/ops/tests/01_fast_callback_options.rs @@ -0,0 +1,11 @@ +use deno_core::v8::fast_api::FastApiCallbackOptions; +use deno_ops::op; + +#[op(fast)] +fn op_fallback(options: Option<&mut FastApiCallbackOptions>) { + if let Some(options) = options { + options.fallback = true; + } +} + +fn main() {} diff --git a/ops/tests/compile_fail/unsupported.rs b/ops/tests/compile_fail/unsupported.rs index 1c4d6407a..52d55de5b 100644 --- a/ops/tests/compile_fail/unsupported.rs +++ b/ops/tests/compile_fail/unsupported.rs @@ -17,6 +17,13 @@ fn op_u16_arg(a: u16, b: u16) { // } +use deno_core::v8::fast_api::FastApiCallbackOptions; + +#[op(fast)] +fn op_callback_options(options: &mut FastApiCallbackOptions) { + // fast callback options must be an Option. +} + #[op(fast)] async fn op_async_fn(a: i32, b: i32) -> i32 { a + b diff --git a/ops/tests/compile_fail/unsupported.stderr b/ops/tests/compile_fail/unsupported.stderr index 68c9f7f16..88d1c1fe4 100644 --- a/ops/tests/compile_fail/unsupported.stderr +++ b/ops/tests/compile_fail/unsupported.stderr @@ -23,9 +23,25 @@ error: custom attribute panicked = help: message: op cannot be a fast api. enforced by #[op(fast)] error: custom attribute panicked - --> tests/compile_fail/unsupported.rs:20:1 + --> tests/compile_fail/unsupported.rs:22:1 | -20 | #[op(fast)] +22 | #[op(fast)] + | ^^^^^^^^^^^ + | + = help: message: op cannot be a fast api. enforced by #[op(fast)] + +error: custom attribute panicked + --> tests/compile_fail/unsupported.rs:27:1 + | +27 | #[op(fast)] | ^^^^^^^^^^^ | = help: message: async op cannot be a fast api. enforced by #[op(fast)] + +warning: unused import: `deno_core::v8::fast_api::FastApiCallbackOptions` + --> tests/compile_fail/unsupported.rs:20:5 + | +20 | use deno_core::v8::fast_api::FastApiCallbackOptions; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(unused_imports)]` on by default diff --git a/ops/tests/mod.rs b/ops/tests/mod.rs index 522647f51..699bcf9f4 100644 --- a/ops/tests/mod.rs +++ b/ops/tests/mod.rs @@ -2,4 +2,5 @@ fn op_macro() { let t = trybuild::TestCases::new(); t.compile_fail("tests/compile_fail/*.rs"); + t.pass("tests/01_fast_callback_options.rs"); } |